summaryrefslogtreecommitdiff
path: root/tests/httpwrappers/tests.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-06-29 15:41:57 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-06-29 18:49:36 +0200
commit8b9b8d3bda09eb1b447631182d06c6c5e51425f6 (patch)
treeb32519d4d91f5c60e72a284345fcf2487afc66c7 /tests/httpwrappers/tests.py
parent59b0c48ce27951048146358739baf08056c5e821 (diff)
downloaddjango-8b9b8d3bda09eb1b447631182d06c6c5e51425f6.tar.gz
Removed compatibility code for streaming responses.
This code provided a deprecation path for old-style streaming responses. Refs #6527, #7581.
Diffstat (limited to 'tests/httpwrappers/tests.py')
-rw-r--r--tests/httpwrappers/tests.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index 194232e92f..673409fd99 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -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('!')