mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #28679 -- Fixed urlencode()'s handling of bytes.
Regression in fee42fd99e.
Thanks Claude Paroz, Jon Dufresne, and Tim Graham for the guidance.
This commit is contained in:
committed by
Tim Graham
parent
4d60261b2a
commit
41be85862d
@@ -47,6 +47,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