Skip to content

Commit 249a42f

Browse files
fixup
1 parent e809ac2 commit 249a42f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pandas/tests/indexes/test_setops.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def test_intersection_difference_match_empty(self, index, sort):
530530
@pytest.mark.parametrize(
531531
"method", ["intersection", "union", "difference", "symmetric_difference"]
532532
)
533-
def test_setop_with_categorical(index_flat, sort, method):
533+
def test_setop_with_categorical(index_flat, sort, method, using_infer_string):
534534
# MultiIndex tested separately in tests.indexes.multi.test_setops
535535
index = index_flat
536536

@@ -539,13 +539,21 @@ def test_setop_with_categorical(index_flat, sort, method):
539539

540540
result = getattr(index, method)(other, sort=sort)
541541
expected = getattr(index, method)(index, sort=sort)
542-
if index.empty and method in ("union", "symmetric_difference"):
542+
if (
543+
using_infer_string
544+
and index.empty
545+
and method in ("union", "symmetric_difference")
546+
):
543547
expected = expected.astype("category")
544548
tm.assert_index_equal(result, expected, exact=exact)
545549

546550
result = getattr(index, method)(other[:5], sort=sort)
547551
expected = getattr(index, method)(index[:5], sort=sort)
548-
if index.empty and method in ("union", "symmetric_difference"):
552+
if (
553+
using_infer_string
554+
and index.empty
555+
and method in ("union", "symmetric_difference")
556+
):
549557
expected = expected.astype("category")
550558
tm.assert_index_equal(result, expected, exact=exact)
551559

0 commit comments

Comments
 (0)