aboutsummaryrefslogtreecommitdiffstats
path: root/test_json_diff.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-11-29 18:56:25 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-11-29 18:56:25 +0100
commit2f56bd116a0b29aef3d3475ad4d70d6935a41727 (patch)
tree1da507ecb6c6670ffa472a3b9a25bc64d8735ecd /test_json_diff.py
parentf294826709fe69222a164acdb8e14c965deafe91 (diff)
downloadjson_diff-2f56bd116a0b29aef3d3475ad4d70d6935a41727.tar.gz
Add option -a to ignore appended keys (for comparing changing piglit tests).
Fix #35
Diffstat (limited to 'test_json_diff.py')
-rw-r--r--test_json_diff.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/test_json_diff.py b/test_json_diff.py
index 5b93044..21cd7af 100644
--- a/test_json_diff.py
+++ b/test_json_diff.py
@@ -14,11 +14,12 @@ import codecs
from test_strings import ARRAY_DIFF, ARRAY_NEW, ARRAY_OLD, \
NESTED_DIFF, NESTED_DIFF_EXCL, NESTED_DIFF_INCL, NESTED_NEW, NESTED_OLD, \
NO_JSON_NEW, NO_JSON_OLD, SIMPLE_ARRAY_DIFF, SIMPLE_ARRAY_NEW, \
+ NESTED_DIFF_IGNORING, \
SIMPLE_ARRAY_OLD, SIMPLE_DIFF, SIMPLE_DIFF_HTML, SIMPLE_NEW, SIMPLE_OLD
class OurTestCase(unittest.TestCase):
- def _run_test(self, oldf, newf, difff, msg="", inc=(), exc=()):
- diffator = json_diff.Comparator(oldf, newf, inc, exc)
+ def _run_test(self, oldf, newf, difff, msg="", opts=None):
+ diffator = json_diff.Comparator(oldf, newf, opts)
diff = diffator.compare_dicts()
expected = json.load(difff)
self.assertEqual(json.dumps(diff, sort_keys=True), json.dumps(expected, sort_keys=True),
@@ -26,11 +27,12 @@ class OurTestCase(unittest.TestCase):
(json.dumps(expected, sort_keys=True, indent=4, ensure_ascii=False),
json.dumps(diff, sort_keys=True, indent=4, ensure_ascii=False)))
- def _run_test_strings(self, olds, news, diffs, msg="", inc=(), exc=()):
- self._run_test(StringIO(olds), StringIO(news), StringIO(diffs), msg, inc, exc)
+ def _run_test_strings(self, olds, news, diffs, msg="", opts=None):
+ self._run_test(StringIO(olds), StringIO(news), StringIO(diffs),
+ msg, opts)
- def _run_test_formatted(self, oldf, newf, difff, msg=""):
- diffator = json_diff.Comparator(oldf, newf)
+ def _run_test_formatted(self, oldf, newf, difff, msg="", opts=None):
+ diffator = json_diff.Comparator(oldf, newf, opts)
diff = ("\n".join([line.strip() \
for line in unicode( \
json_diff.HTMLFormatter(diffator.compare_dicts())).split("\n")])).strip()
@@ -133,7 +135,8 @@ class TestPiglitData(OurTestCase):
def test_piglit_result_only(self):
self._run_test(open("test/old-testing-data.json"), open("test/new-testing-data.json"),
open("test/diff-result-only-testing-data.json"),
- "Large piglit reports diff (just resume field).", inc=('result',))
+ "Large piglit reports diff (just resume field).",
+ {'included_attrs': ("result",)})
if __name__ == "__main__":
unittest.main()