Skip to content

ENH: Informative dtype message for for assert_series_equal #28993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/tests/util/test_assert_frame_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_empty_dtypes(check_dtype):
df1["col1"] = df1["col1"].astype("int64")

if check_dtype:
msg = "Attributes are different"
msg = r"Attributes of DataFrame\..* are different"
with pytest.raises(AssertionError, match=msg):
assert_frame_equal(df1, df2, **kwargs)
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/util/test_assert_series_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_series_equal_values_mismatch(check_less_precise):


def test_series_equal_categorical_mismatch(check_categorical):
msg = """Attributes are different
msg = """Attributes of Series are different

Attribute "dtype" are different
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)
Expand Down
7 changes: 5 additions & 2 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,9 @@ def assert_series_equal(
):
pass
else:
assert_attr_equal("dtype", left, right)
assert_attr_equal(
"dtype", left, right, obj="Attributes of {obj}".format(obj=obj)
)

if check_exact:
assert_numpy_array_equal(
Expand Down Expand Up @@ -1315,8 +1317,9 @@ def assert_frame_equal(

>>> assert_frame_equal(df1, df2)
Traceback (most recent call last):
AssertionError: Attributes are different
...
AssertionError: Attributes of DataFrame.iloc[:, 1] are different

Attribute "dtype" are different
[left]: int64
[right]: float64
Expand Down