diff options
Diffstat (limited to 'templates/python/template.py')
-rw-r--r-- | templates/python/template.py | 14 |
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() |