From ba94e5f84b85f7d27171ac219666ae4248d56e41 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Mon, 6 Apr 2020 14:50:10 +0100 Subject: [PATCH 1/2] TST: Don't use 'is' on strings to avoid SyntaxWarning --- pandas/tests/frame/test_alter_axes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_alter_axes.py b/pandas/tests/frame/test_alter_axes.py index 961c18749f055..d4cb88acf1129 100644 --- a/pandas/tests/frame/test_alter_axes.py +++ b/pandas/tests/frame/test_alter_axes.py @@ -234,9 +234,16 @@ def test_set_index_pass_arrays_duplicate( # 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 ( + type(keys[0]) == str + and keys[0] == "A" + and type(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 From 29e54545b8e3b91ea5f9e13311ddc5094400fa16 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Mon, 6 Apr 2020 17:15:02 +0100 Subject: [PATCH 2/2] use isinstance --- pandas/tests/frame/test_alter_axes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_alter_axes.py b/pandas/tests/frame/test_alter_axes.py index d4cb88acf1129..b28e8a5b347aa 100644 --- a/pandas/tests/frame/test_alter_axes.py +++ b/pandas/tests/frame/test_alter_axes.py @@ -238,9 +238,9 @@ def test_set_index_pass_arrays_duplicate( first_drop = ( False if ( - type(keys[0]) == str + isinstance(keys[0], str) and keys[0] == "A" - and type(keys[1]) == str + and isinstance(keys[1], str) and keys[1] == "A" ) else drop