Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: 
Changeset: r93397:1aa1bd29a7b8
Date: 2017-12-12 20:05 +0100
http://bitbucket.org/pypy/pypy/changeset/1aa1bd29a7b8/

Log:    because it's easy: add a json roundtrip hypothesis test

diff --git a/extra_tests/test_json.py b/extra_tests/test_json.py
--- a/extra_tests/test_json.py
+++ b/extra_tests/test_json.py
@@ -1,5 +1,6 @@
 import pytest
 import json
+from hypothesis import given, strategies
 
 def is_(x, y):
     return type(x) is type(y) and x == y
@@ -18,3 +19,15 @@
 
 def test_issue2191():
     assert is_(json.dumps(u"xxx", ensure_ascii=False), u'"xxx"')
+
+jsondata = strategies.recursive(
+    strategies.none() |
+    strategies.booleans() |
+    strategies.floats(allow_nan=False) |
+    strategies.text(),
+    lambda children: strategies.lists(children) |
+        strategies.dictionaries(strategies.text(), children))
+
+@given(jsondata)
+def test_roundtrip(d):
+    assert json.loads(json.dumps(d)) == d
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to