1
0
mirror of https://github.com/django/django.git synced 2025-10-30 00:56:09 +00:00

Removed compatibility code for streaming responses.

This code provided a deprecation path for old-style streaming responses.

Refs #6527, #7581.
This commit is contained in:
Aymeric Augustin
2013-06-29 15:41:57 +02:00
parent 59b0c48ce2
commit 8b9b8d3bda
4 changed files with 16 additions and 86 deletions

View File

@@ -324,19 +324,10 @@ class HttpResponseTests(unittest.TestCase):
r.content = [1, 2, 3]
self.assertEqual(r.content, b'123')
#test retrieval explicitly using iter (deprecated) and odd inputs
#test odd inputs
r = HttpResponse()
r.content = ['1', '2', 3, '\u079e']
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", DeprecationWarning)
my_iter = iter(r)
self.assertEqual(w[0].category, DeprecationWarning)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", DeprecationWarning)
result = list(my_iter)
self.assertEqual(w[0].category, DeprecationWarning)
#'\xde\x9e' == unichr(1950).encode('utf-8')
self.assertEqual(result, [b'1', b'2', b'3', b'\xde\x9e'])
self.assertEqual(r.content, b'123\xde\x9e')
#with Content-Encoding header
@@ -344,9 +335,8 @@ class HttpResponseTests(unittest.TestCase):
r['Content-Encoding'] = 'winning'
r.content = [b'abc', b'def']
self.assertEqual(r.content, b'abcdef')
r.content = ['\u079e']
self.assertRaises(TypeError if six.PY3 else UnicodeEncodeError,
getattr, r, 'content')
setattr, r, 'content', ['\u079e'])
# .content can safely be accessed multiple times.
r = HttpResponse(iter(['hello', 'world']))
@@ -358,15 +348,12 @@ class HttpResponseTests(unittest.TestCase):
# accessing .content still works
self.assertEqual(r.content, b'helloworld')
# XXX accessing .content doesn't work if the response was iterated first
# XXX change this when the deprecation completes in HttpResponse
# Accessing .content also works if the response was iterated first.
r = HttpResponse(iter(['hello', 'world']))
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
self.assertEqual(b''.join(r), b'helloworld')
self.assertEqual(r.content, b'') # not the expected result!
self.assertEqual(b''.join(r), b'helloworld')
self.assertEqual(r.content, b'helloworld')
# additional content can be written to the response.
# Additional content can be written to the response.
r = HttpResponse(iter(['hello', 'world']))
self.assertEqual(r.content, b'helloworld')
r.write('!')