Skip to content

Commit 12759b4

Browse files
author
Santhosh Kumar Bethi
committed
added test cases for 61473 fix
1 parent 4094088 commit 12759b4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pandas/tests/util/test_assert_frame_equal.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,34 @@ def test_datetimelike_compat_deprecated():
413413
tm.assert_series_equal(df["a"], df["a"], check_datetimelike_compat=True)
414414
with tm.assert_produces_warning(Pandas4Warning, match=msg):
415415
tm.assert_series_equal(df["a"], df["a"], check_datetimelike_compat=False)
416+
417+
418+
def test_assert_frame_equal_na_object_vs_int32_check_dtype_false():
419+
#GH# 61473
420+
df1 = pd.DataFrame({"a": pd.Series([pd.NA], dtype="Int32")})
421+
df2 = pd.DataFrame({"a": pd.Series([pd.NA], dtype="object")})
422+
tm.assert_frame_equal(df1, df2, check_dtype=False)
423+
424+
425+
def test_assert_frame_equal_object_vs_int32_check_dtype_false():
426+
#GH# 61473
427+
df1 = pd.DataFrame({"a": pd.Series([pd.NA,0], dtype="Int32")})
428+
df2 = pd.DataFrame({"a": pd.Series([pd.NA,0], dtype="object")})
429+
tm.assert_frame_equal(df1, df2, check_dtype=False)
430+
431+
432+
def test_assert_frame_not_equal_object_vs_int32_check_dtype_false():
433+
#GH# 61473
434+
df1 = pd.DataFrame({"a": pd.Series([pd.NA,0], dtype="Int32")})
435+
df2 = pd.DataFrame({"a": pd.Series([pd.NA,1], dtype="object")})
436+
msg = (
437+
r"""DataFrame\.iloc\[:, 0\] \(column name="a"\) are different
438+
439+
DataFrame\.iloc\[:, 0\] \(column name="a"\) values are different \(50\.0 %\)
440+
\[index\]: \[0, 1\]
441+
\[left\]: \[<NA>, 0\]
442+
\[right\]: \[<NA>, 1\]"""
443+
)
444+
with pytest.raises(AssertionError, match=msg):
445+
tm.assert_frame_equal(df1, df2, check_dtype=False)
446+

0 commit comments

Comments
 (0)