Skip to content

CI/TST: Change id to is for flaky tests #44650

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 3 commits into from
Nov 28, 2021
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
6 changes: 4 additions & 2 deletions pandas/tests/frame/methods/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ def test_rename_inplace(self, float_frame):
assert "C" in float_frame
assert "foo" not in float_frame

c_id = id(float_frame["C"])
c_values = float_frame["C"]
float_frame = float_frame.copy()
return_value = float_frame.rename(columns={"C": "foo"}, inplace=True)
assert return_value is None

assert "C" not in float_frame
assert "foo" in float_frame
assert id(float_frame["foo"]) != c_id
# GH 44153
# Used to be id(float_frame["foo"]) != c_id, but flaky in the CI
assert float_frame["foo"] is not c_values

def test_rename_bug(self):
# GH 5344
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/frame/methods/test_sort_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ def test_sort_index_inplace(self):

# axis=0
unordered = frame.loc[[3, 2, 4, 1]]
a_id = id(unordered["A"])
a_values = unordered["A"]
df = unordered.copy()
return_value = df.sort_index(inplace=True)
assert return_value is None
expected = frame
tm.assert_frame_equal(df, expected)
assert a_id != id(df["A"])
# GH 44153 related
# Used to be a_id != id(df["A"]), but flaky in the CI
assert a_values is not df["A"]

df = unordered.copy()
return_value = df.sort_index(ascending=False, inplace=True)
Expand Down