summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-24 10:49:37 +0300
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-05-24 08:58:10 +0100
commitf039dc7fcb3e9dd20166ecfe64d5428a812d5990 (patch)
tree0f09e6d77880b3673d6760e78642280d5de0c662 /templates
parentbbdb40ac56d67ffb0d5a1cf582fe15740f1283ce (diff)
downloadsubplot-f039dc7fcb3e9dd20166ecfe64d5428a812d5990.tar.gz
test(sp-meta): amend scenario to also test JSON output
Diffstat (limited to 'templates')
-rw-r--r--templates/python/template.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/templates/python/template.py b/templates/python/template.py
index e430b1b..a1fa3ee 100644
--- a/templates/python/template.py
+++ b/templates/python/template.py
@@ -67,6 +67,20 @@ def assert_eq(a, b):
def assert_ne(a, b):
assert a != b, 'expected %r != %r' % (a, b)
+# Check that two dict values are equal.
+def assert_dict_eq(a, b):
+ assert isinstance(a, dict)
+ assert isinstance(b, dict)
+ for key in a:
+ assert key in b, f"exected {key} in both dicts"
+ av = a[key]
+ bv = b[key]
+ assert_eq(type(av), type(bv))
+ if isinstance(av, list):
+ assert_eq(list(sorted(av)), list(sorted(bv)))
+ for key in b:
+ assert key in a, f"exected {key} in both dicts"
+
# Remember where we started from. The step functions may need to refer
# to files there.
srcdir = os.getcwd()