Skip to content

Commit c358fa1

Browse files
moi90Nico Cernek
authored and
Nico Cernek
committed
ENH: Informative dtype message for for assert_series_equal (pandas-dev#28993)
1 parent 1f5475f commit c358fa1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pandas/tests/util/test_assert_frame_equal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def test_empty_dtypes(check_dtype):
141141
df1["col1"] = df1["col1"].astype("int64")
142142

143143
if check_dtype:
144-
msg = "Attributes are different"
144+
msg = r"Attributes of DataFrame\..* are different"
145145
with pytest.raises(AssertionError, match=msg):
146146
assert_frame_equal(df1, df2, **kwargs)
147147
else:

pandas/tests/util/test_assert_series_equal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_series_equal_values_mismatch(check_less_precise):
179179

180180

181181
def test_series_equal_categorical_mismatch(check_categorical):
182-
msg = """Attributes are different
182+
msg = """Attributes of Series are different
183183
184184
Attribute "dtype" are different
185185
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)

pandas/util/testing.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,9 @@ def assert_series_equal(
11561156
):
11571157
pass
11581158
else:
1159-
assert_attr_equal("dtype", left, right)
1159+
assert_attr_equal(
1160+
"dtype", left, right, obj="Attributes of {obj}".format(obj=obj)
1161+
)
11601162

11611163
if check_exact:
11621164
assert_numpy_array_equal(
@@ -1315,8 +1317,9 @@ def assert_frame_equal(
13151317
13161318
>>> assert_frame_equal(df1, df2)
13171319
Traceback (most recent call last):
1318-
AssertionError: Attributes are different
13191320
...
1321+
AssertionError: Attributes of DataFrame.iloc[:, 1] are different
1322+
13201323
Attribute "dtype" are different
13211324
[left]: int64
13221325
[right]: float64

0 commit comments

Comments
 (0)