testutil: Improve check_post_meta error reporting.

This version makes it easier to get diffs between the expected
and actual metadata.
This commit is contained in:
Brett Smith 2020-03-19 09:32:06 -04:00
parent cbd94d9b75
commit f1c115de49

View file

@ -33,8 +33,10 @@ def check_post_meta(txn, *expected_meta, default=None):
if not expected:
assert not post.meta
else:
assert all(post.meta.get(key, default) == value
for key, value in expected.items())
actual = None if post.meta is None else {
key: post.meta.get(key, default) for key in expected
}
assert actual == expected
def parse_date(s, fmt='%Y-%m-%d'):
return datetime.datetime.strptime(s, fmt).date()