Skip to main content

assert_table_equal()

Assert that actual matches expected, for use in tests.

Usage

Source

assert_table_equal(
    actual,
    expected,
    *,
    rel_tol=_UNSET,
    max_rows=10,
    **kwargs,
)

Runs diff_table(expected, actual, ...), with expected as the benchmark, and raises AssertionError with diff_summary() and the first max_rows records that differ. Tables that share no key fail too. Other keyword arguments go to diff_table().

rel_tol defaults to sqrt(eps) (about 1.5e-8), as pytest and testthat compare floats, where diff_table() is exact; with duplicates="aggregate", which compares exactly, it defaults to 0. Repeated keys of rows with measures are a DiffError unless duplicates is given: an assertion must not decide identity by arrival order. Repeated whole rows are paired, since they are identical.

Returns the comparison when the tables match.