diff options
author | Claude Paroz <claude@2xlibre.net> | 2017-01-20 10:20:53 +0100 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2017-01-20 14:13:55 +0100 |
commit | 042b7350a080cc964f913faf1cf7f0097f650a58 (patch) | |
tree | 4ad77d8fc8ae016770afe01a543a6042fa02357a /tests/httpwrappers | |
parent | 4e729feaa647547f25debb1cb63dec989dc41a20 (diff) | |
download | django-042b7350a080cc964f913faf1cf7f0097f650a58.tar.gz |
Refs #23919 -- Removed unneeded str() calls
Diffstat (limited to 'tests/httpwrappers')
-rw-r--r-- | tests/httpwrappers/tests.py | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index 612cbb45ef..c58163b014 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -21,7 +21,7 @@ from django.utils.functional import lazystr class QueryDictTests(SimpleTestCase): def test_create_with_no_args(self): - self.assertEqual(QueryDict(), QueryDict(str(''))) + self.assertEqual(QueryDict(), QueryDict('')) def test_missing_key(self): q = QueryDict() @@ -63,7 +63,7 @@ class QueryDictTests(SimpleTestCase): def test_single_key_value(self): """Test QueryDict with one key/value pair""" - q = QueryDict(str('foo=bar')) + q = QueryDict('foo=bar') self.assertEqual(q['foo'], 'bar') with self.assertRaises(KeyError): q.__getitem__('bar') @@ -166,7 +166,7 @@ class QueryDictTests(SimpleTestCase): def test_multiple_keys(self): """Test QueryDict with two key/value pairs with same keys.""" - q = QueryDict(str('vote=yes&vote=no')) + q = QueryDict('vote=yes&vote=no') self.assertEqual(q['vote'], 'no') with self.assertRaises(AttributeError): @@ -209,23 +209,23 @@ class QueryDictTests(SimpleTestCase): q = QueryDict() q1 = pickle.loads(pickle.dumps(q, 2)) self.assertEqual(q, q1) - q = QueryDict(str('a=b&c=d')) + q = QueryDict('a=b&c=d') q1 = pickle.loads(pickle.dumps(q, 2)) self.assertEqual(q, q1) - q = QueryDict(str('a=b&c=d&a=1')) + q = QueryDict('a=b&c=d&a=1') q1 = pickle.loads(pickle.dumps(q, 2)) self.assertEqual(q, q1) def test_update_from_querydict(self): """Regression test for #8278: QueryDict.update(QueryDict)""" - x = QueryDict(str("a=1&a=2"), mutable=True) - y = QueryDict(str("a=3&a=4")) + x = QueryDict("a=1&a=2", mutable=True) + y = QueryDict("a=3&a=4") x.update(y) self.assertEqual(x.getlist('a'), ['1', '2', '3', '4']) def test_non_default_encoding(self): """#13572 - QueryDict with a non-default encoding""" - q = QueryDict(str('cur=%A4'), encoding='iso-8859-15') + q = QueryDict('cur=%A4', encoding='iso-8859-15') self.assertEqual(q.encoding, 'iso-8859-15') self.assertEqual(list(q.items()), [('cur', '€')]) self.assertEqual(q.urlencode(), 'cur=%A4') @@ -280,16 +280,11 @@ class HttpResponseTests(unittest.TestCase): def test_headers_type(self): r = HttpResponse() - # The following tests explicitly test types in addition to values - # because in Python 2 u'foo' == b'foo'. - - # ASCII unicode or bytes values are converted to native strings. + # ASCII unicode or bytes values are converted to strings. r['key'] = 'test' - self.assertEqual(r['key'], str('test')) - self.assertIsInstance(r['key'], str) + self.assertEqual(r['key'], 'test') r['key'] = 'test'.encode('ascii') - self.assertEqual(r['key'], str('test')) - self.assertIsInstance(r['key'], str) + self.assertEqual(r['key'], 'test') self.assertIn(b'test', r.serialize_headers()) # Non-ASCII values are serialized to Latin-1. @@ -298,8 +293,7 @@ class HttpResponseTests(unittest.TestCase): # Other unicode values are MIME-encoded (there's no way to pass them as bytes). r['key'] = '†' - self.assertEqual(r['key'], str('=?utf-8?b?4oCg?=')) - self.assertIsInstance(r['key'], str) + self.assertEqual(r['key'], '=?utf-8?b?4oCg?=') self.assertIn(b'=?utf-8?b?4oCg?=', r.serialize_headers()) # The response also converts unicode or bytes keys to strings, but requires @@ -310,7 +304,6 @@ class HttpResponseTests(unittest.TestCase): headers = list(r.items()) self.assertEqual(len(headers), 1) self.assertEqual(headers[0], ('foo', 'bar')) - self.assertIsInstance(headers[0][0], str) r = HttpResponse() del r['Content-Type'] |