Skip to content

TST: Make understandable assertion messages #10373

Closed
@sinhrks

Description

@sinhrks

I think making assertion messages more understandable helps users who is starting contribution / using pandas as their dependencies. I'm considering examples like power assert, but more focuses what's differences are.

If it worth to be discussed, I'll prepare more examples to fix the specifications.

df1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}, index=['a', 'b'])
df2 = pd.DataFrame({'A': [1, 2], 'B': [3, 5]}, index=['a', 'c'])

assert_frame_equal(df1, df2)
# AssertionError: DataFrames are not equal
# [values]: [[1 3] [2 4]] != [[1 3] [2 5]]
# [index values] ['a', 'b'] != ['a', 'c']
# [columns]: equal

idx1 = pd.Index([1, 2], name='x')
idx2 = pd.Index([1, 2], name='y')
assert_index_equal(idx1, idx2)
# AssertionError: Index are not equal
# [values]: equal
# [names]: 'x' != 'y' 

First target should be:

  • assert_frame_equal
  • assert_series_equal
  • assert_index_equal

Metadata

Metadata

Assignees

No one assigned

    Labels

    Testingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions