Skip to content

Commit 66a3d17

Browse files
TST: Don't use 'is' on strings to avoid SyntaxWarning (#33322)
1 parent 0647850 commit 66a3d17

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pandas/tests/frame/test_alter_axes.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,16 @@ def test_set_index_pass_arrays_duplicate(
234234

235235
# need to adapt first drop for case that both keys are 'A' --
236236
# cannot drop the same column twice;
237-
# use "is" because == would give ambiguous Boolean error for containers
237+
# plain == would give ambiguous Boolean error for containers
238238
first_drop = (
239-
False if (keys[0] is "A" and keys[1] is "A") else drop # noqa: F632
239+
False
240+
if (
241+
isinstance(keys[0], str)
242+
and keys[0] == "A"
243+
and isinstance(keys[1], str)
244+
and keys[1] == "A"
245+
)
246+
else drop
240247
)
241248
# to test against already-tested behaviour, we add sequentially,
242249
# hence second append always True; must wrap keys in list, otherwise

0 commit comments

Comments
 (0)