diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-12-27 11:19:55 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-12-27 11:19:55 -0500 |
commit | 6fe9c45b725cd21eacbb50263bd3449e1a3edf17 (patch) | |
tree | 76c94d830c0c1e17d1d7580743908eb0aacc134e /tests/test_client | |
parent | 293db9eb36e42e8ba976c2639800020d04b95deb (diff) | |
download | django-6fe9c45b725cd21eacbb50263bd3449e1a3edf17.tar.gz |
Fixed #30024 -- Made urlencode() and Client raise TypeError when None is passed as data.
Diffstat (limited to 'tests/test_client')
-rw-r--r-- | tests/test_client/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index bb6c8bbff0..432865328f 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -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') |