Skip to content

Commit e8fe687

Browse files
committed
TST: add test with mock
1 parent fd5dc65 commit e8fe687

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/util/test_assert_frame_equal.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import patch
2+
13
import pytest
24

35
import pandas as pd
@@ -285,3 +287,15 @@ def test_allows_duplicate_labels():
285287

286288
with pytest.raises(AssertionError, match="<Flags"):
287289
tm.assert_frame_equal(left, right)
290+
291+
292+
def test_assert_frame_equal_checks_index_exactly_twice():
293+
data = {"col1": [1, 2, 3], "col2": [4, 5, 6]}
294+
left = DataFrame(data, index=["a", "b", "c"])
295+
right = DataFrame(data, index=["a", "b", "c"])
296+
with patch("pandas._testing.assert_index_equal", return_value=None) as mock:
297+
tm.assert_frame_equal(left, right)
298+
# Expect exactly two calls:
299+
# 1. Index equality
300+
# 2. Columns equality
301+
assert mock.call_count == 2

0 commit comments

Comments
 (0)