mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[2.0.x] Fixed #28679 -- Fixed urlencode()'s handling of bytes.
Regression infee42fd99e. Thanks Claude Paroz, Jon Dufresne, and Tim Graham for the guidance. Backport of41be85862dfrom master
This commit is contained in:
committed by
Tim Graham
parent
2a55063dcc
commit
51998a2988
@@ -49,6 +49,23 @@ class URLEncodeTests(unittest.TestCase):
|
||||
'position=Developer&name=Adrian&name=Simon',
|
||||
])
|
||||
|
||||
def test_dict_with_bytes_values(self):
|
||||
self.assertEqual(urlencode({'a': b'abc'}, doseq=True), 'a=abc')
|
||||
|
||||
def test_dict_with_sequence_of_bytes(self):
|
||||
self.assertEqual(urlencode({'a': [b'spam', b'eggs', b'bacon']}, doseq=True), 'a=spam&a=eggs&a=bacon')
|
||||
|
||||
def test_dict_with_bytearray(self):
|
||||
self.assertEqual(urlencode({'a': bytearray(range(2))}, doseq=True), 'a=0&a=1')
|
||||
self.assertEqual(urlencode({'a': bytearray(range(2))}, doseq=False), 'a=%5B%270%27%2C+%271%27%5D')
|
||||
|
||||
def test_generator(self):
|
||||
def gen():
|
||||
yield from range(2)
|
||||
|
||||
self.assertEqual(urlencode({'a': gen()}, doseq=True), 'a=0&a=1')
|
||||
self.assertEqual(urlencode({'a': gen()}, doseq=False), 'a=%5B%270%27%2C+%271%27%5D')
|
||||
|
||||
|
||||
class Base36IntTests(SimpleTestCase):
|
||||
def test_roundtrip(self):
|
||||
|
||||
Reference in New Issue
Block a user