Skip to content

Instantly share code, notes, and snippets.

@claudep
Created March 7, 2017 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudep/133ed167be5b3d85013812a8a385555b to your computer and use it in GitHub Desktop.
Save claudep/133ed167be5b3d85013812a8a385555b to your computer and use it in GitHub Desktop.
Test for #27895
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index c9dffdb..0233786 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -1200,6 +1200,21 @@ class RequestMethodStringDataTests(SimpleTestCase):
response = self.client.get('/json_response/')
self.assertEqual(response.json(), {'key': 'value'})
+ def test_json_non_ascii(self):
+ """Test with both escaped and non-escaped UTF-8 content."""
+ response = self.client.post(
+ '/parse_unicode_json/',
+ '{"dog": "собака"}',
+ content_type="application/json; charset=utf-8",
+ )
+ self.assertEqual(response.json(), {"dog": "собака"})
+ response = self.client.post(
+ '/parse_unicode_json/',
+ '{"dog": "\\u0441\\u043e\\u0431\\u0430\\u043a\\u0430"}',
+ content_type="application/json; charset=utf-8",
+ )
+ self.assertEqual(response.json(), {"dog": "собака"})
+
def test_json_vendor(self):
valid_types = (
'application/vnd.api+json',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment