testudos.testing.assertions
testudos.testing.assertions
Test assertions: hard failures (test) and soft failures (expect).
Hard assertions raise AssertionError immediately (gtest ASSERT_* style). Soft assertions record failures and raise once when verify_all() is called (gtest EXPECT_* style). Pytest runs verify_all() automatically after each test.
TestAPI Objects
class TestAPI()Hard assertion helpers for test scripts (gtest ASSERT_* style).
compare(a, b) fails if a != b; verify(condition) fails if not condition; fail(msg) always fails.
compare
def compare(a: Any, b: Any, msg: str | None = None) -> NoneAssert that a equals b. Raises AssertionError if not.
verify
def verify(condition: bool, msg: str | None = None) -> NoneAssert that condition is true. Raises AssertionError if false.
equal
def equal(a: Any, b: Any, msg: str | None = None) -> NoneAlias for compare.
true
def true(condition: bool, msg: str | None = None) -> NoneAlias for verify.
fail
def fail(msg: str | None = None) -> NoneFail the test with an optional message.
compare_images
def compare_images(actual_path: str, baseline_path: str, tolerance: float = 0.0, msg: str | None = None) -> NoneCompare two image files and fail the test if they differ.
compare_screenshot
def compare_screenshot(target: Any, baseline_path: str, temp_path: str | None = None, tolerance: float = 0.0) -> NoneCapture a screenshot of a Qt object and compare it to a baseline image.
ExpectAPI Objects
class ExpectAPI()Soft assertion helpers (gtest EXPECT_* style).
Record failures without stopping the test. Call verify_all() to raise a single AssertionError listing all recorded failures (pytest does this automatically).
compare
def compare(a: Any, b: Any, msg: str | None = None) -> NoneRecord a failure if a does not equal b.
verify
def verify(condition: bool, msg: str | None = None) -> NoneRecord a failure if condition is false.
equal
def equal(a: Any, b: Any, msg: str | None = None) -> NoneAlias for compare.
true
def true(condition: bool, msg: str | None = None) -> NoneAlias for verify.
compare_images
def compare_images(actual_path: str, baseline_path: str, tolerance: float = 0.0, msg: str | None = None) -> NoneRecord a failure if two image files differ.
compare_screenshot
def compare_screenshot(target: Any, baseline_path: str, temp_path: str | None = None, tolerance: float = 0.0) -> NoneCapture a screenshot and record a failure if it differs from baseline.
verify_all
def verify_all() -> NoneRaise AssertionError if any soft assertion failed.
clear
def clear() -> NoneDiscard recorded failures.
failures
@propertydef failures() -> list[str]Return a copy of recorded failure messages.