diff --git a/pandas/tests/frame/test_alter_axes.py b/pandas/tests/frame/test_alter_axes.py
index <HASH>..<HASH> 100644
--- a/pandas/tests/frame/test_alter_axes.py
+++ b/pandas/tests/frame/test_alter_axes.py
@@ -234,9 +234,16 @@ class TestDataFrameAlterAxes:
 
         # need to adapt first drop for case that both keys are 'A' --
         # cannot drop the same column twice;
-        # use "is" because == would give ambiguous Boolean error for containers
+        # plain == would give ambiguous Boolean error for containers
         first_drop = (
-            False if (keys[0] is "A" and keys[1] is "A") else drop  # noqa: F632
+            False
+            if (
+                isinstance(keys[0], str)
+                and keys[0] == "A"
+                and isinstance(keys[1], str)
+                and keys[1] == "A"
+            )
+            else drop
         )
         # to test against already-tested behaviour, we add sequentially,
         # hence second append always True; must wrap keys in list, otherwise
TST: Don't use 'is' on strings to avoid SyntaxWarning (#<I>)