diff options
Diffstat (limited to 'tests/httpwrappers/tests.py')
-rw-r--r-- | tests/httpwrappers/tests.py | 25 |
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('!') |