Skip to content

"During handling of the above exception, another exception occurred" with DataFrames #18

Description

@dpinol

The following test...

        df1 = pl.DataFrame({"a": [1, 2], "b": [4, 5]})
        df2 = pl.DataFrame({"a": [1, 2], "b": [4, 6]})
        assert_that(df1).is_frame_equal(df2)

Causes a long callstack, with duplicated AssertionError details, and message "During handling of the above exception, another exception occurred"

One solution could be adding from None to raise AssertionFailure(...) within AssertionBuilder.error, or only adding it when a from_none flag is passed to the function. I'm happy to create a PR for any design you prefer.

―――――――――――――――――――――― Test_DataFrame.test_is_frame_equal ――――――――――――――――――――――
.venv/lib/python3.14/site-packages/polars/_utils/deprecation.py:132: in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.14/site-packages/polars/_utils/deprecation.py:132: in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.14/site-packages/polars/_utils/deprecation.py:132: in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
E   AssertionError: DataFrames are different (value mismatch for column "b")
E   [left]: shape: (2,)
E   Series: 'b' [i64]
E   [
E   	4
E   	5
E   ]
E   [right]: shape: (2,)
E   Series: 'b' [i64]
E   [
E   	4
E   	6
E   ]

During handling of the above exception, another exception occurred:
test/utils/test_asserts.py:468: in test_is_frame_equal
    assert_that(df1).is_frame_equal(df2)
E   AssertionError: Expected the DataFrame to equal the expected one, but they differ:
E   DataFrames are different (value mismatch for column "b")
E   [left]: shape: (2,)
E   Series: 'b' [i64]
E   [
E   	4
E   	5
E   ]
E   [right]: shape: (2,)
E   Series: 'b' [i64]
E   [
E   	4
E   	6
E   ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions