aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Lamy <ronan.lamy@gmail.com>2017-12-12 18:22:58 +0000
committerRonan Lamy <ronan.lamy@gmail.com>2017-12-12 18:22:58 +0000
commit26b955e91fe91ecfe6bec7db8db2590184d2312c (patch)
treebd2d765aaa9f7b248cf3fe8c0d40896b093359c5 /extra_tests/test_json.py
parentmerge rdict-fast-hash: (diff)
downloadpypy-26b955e91fe91ecfe6bec7db8db2590184d2312c.tar.gz
pypy-26b955e91fe91ecfe6bec7db8db2590184d2312c.tar.bz2
pypy-26b955e91fe91ecfe6bec7db8db2590184d2312c.zip
Move test_json_extra to extra_tests/
Diffstat (limited to 'extra_tests/test_json.py')
-rw-r--r--extra_tests/test_json.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/extra_tests/test_json.py b/extra_tests/test_json.py
new file mode 100644
index 0000000000..3781881604
--- /dev/null
+++ b/extra_tests/test_json.py
@@ -0,0 +1,20 @@
+import pytest
+import json
+
+def is_(x, y):
+ return type(x) is type(y) and x == y
+
+def test_no_ensure_ascii():
+ assert is_(json.dumps(u"\u1234", ensure_ascii=False), u'"\u1234"')
+ assert is_(json.dumps("\xc0", ensure_ascii=False), '"\xc0"')
+ with pytest.raises(UnicodeDecodeError) as excinfo:
+ json.dumps((u"\u1234", "\xc0"), ensure_ascii=False)
+ assert str(excinfo.value).startswith(
+ "'ascii' codec can't decode byte 0xc0 ")
+ with pytest.raises(UnicodeDecodeError) as excinfo:
+ json.dumps(("\xc0", u"\u1234"), ensure_ascii=False)
+ assert str(excinfo.value).startswith(
+ "'ascii' codec can't decode byte 0xc0 ")
+
+def test_issue2191():
+ assert is_(json.dumps(u"xxx", ensure_ascii=False), u'"xxx"')