pola-rs/polars · error · AssertionError

{objects} are equal (but are expected not to be)

Error message

{objects} are equal (but are expected not to be)

What it means

assert_frame_not_equal calls assert_frame_equal and expects an AssertionError; when none is raised the else branch constructs this message (choosing 'LazyFrames' or 'DataFrames' based on input type) and raises. It is a sentinel failure of the negative assertion: the two frames are actually identical under the given tolerance/check options.

Source

Thrown at py-polars/src/polars/testing/asserts/frame.py:240

    lazy = _assert_correct_input_type(left, right)
    try:
        assert_frame_equal(
            left=left,
            right=right,
            check_column_order=check_column_order,
            check_row_order=check_row_order,
            check_dtypes=check_dtypes,
            check_exact=check_exact,
            rel_tol=rel_tol,
            abs_tol=abs_tol,
            categorical_as_str=categorical_as_str,
        )
    except AssertionError:
        return
    else:
        objects = "LazyFrames" if lazy else "DataFrames"
        msg = f"{objects} are equal (but are expected not to be)"
        raise AssertionError(msg)

View on GitHub (pinned to 5d8ebabf11)

Solutions

  1. Use `assert_frame_equal` if you expect equality; if you expect difference, change the inputs so the frames actually differ.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at py-polars/src/polars/testing/asserts/frame.py:231 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-19). Data as JSON: /api/errors/b9d252d95b8b02ab. Report an issue: GitHub.