qa: Add assert_true()

This follows the style of ASSERT_TRUE() in GoogleTest: https://google.github.io/googletest/reference/assertions.html
This commit is contained in:
Hodlinator 2025-02-17 14:23:51 +01:00
parent 0b48f77e10
commit ae4730ea12
No known key found for this signature in database

View File

@ -69,6 +69,14 @@ def summarise_dict_differences(thing1, thing2):
d2[k] = thing2[k]
return d1, d2
def assert_true(condition: bool) -> None:
"""Separate from the `assert` keyword in that it should not be optimized out
when environment var `PYTHONOPTIMIZE=1`, or Python is run with `-O`."""
if not condition:
raise AssertionError
def assert_equal(thing1, thing2, *args):
if thing1 != thing2 and not args and isinstance(thing1, dict) and isinstance(thing2, dict):
d1,d2 = summarise_dict_differences(thing1, thing2)