mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #30024 -- Made urlencode() and Client raise TypeError when None is passed as data.
This commit is contained in:
parent
293db9eb36
commit
6fe9c45b72
5 changed files with 64 additions and 8 deletions
|
@ -59,6 +59,14 @@ class ClientTest(TestCase):
|
|||
response = self.client.get('/get_view/?var=1\ufffd')
|
||||
self.assertEqual(response.context['var'], '1\ufffd')
|
||||
|
||||
def test_get_data_none(self):
|
||||
msg = (
|
||||
'Cannot encode None in a query string. Did you mean to pass an '
|
||||
'empty string or omit the value?'
|
||||
)
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
self.client.get('/get_view/', {'value': None})
|
||||
|
||||
def test_get_post_view(self):
|
||||
"GET a view that normally expects POSTs"
|
||||
response = self.client.get('/post_view/', {})
|
||||
|
@ -92,6 +100,14 @@ class ClientTest(TestCase):
|
|||
self.assertEqual(response.templates[0].name, 'POST Template')
|
||||
self.assertContains(response, 'Data received')
|
||||
|
||||
def test_post_data_none(self):
|
||||
msg = (
|
||||
'Cannot encode None as POST data. Did you mean to pass an empty '
|
||||
'string or omit the value?'
|
||||
)
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
self.client.post('/post_view/', {'value': None})
|
||||
|
||||
def test_json_serialization(self):
|
||||
"""The test client serializes JSON data."""
|
||||
methods = ('post', 'put', 'patch', 'delete')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue