Skip to content

Commit c6179ce

Browse files
TST: Use indices fixture in tests/indexes/test_setops.py (#32964)
1 parent aeb9040 commit c6179ce

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

pandas/conftest.py

+4
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ def indices(request):
418418
return indices_dict[request.param].copy()
419419

420420

421+
# Needed to generate cartesian product of indices
422+
index_fixture2 = indices
423+
424+
421425
# ----------------------------------------------------------------
422426
# Series'
423427
# ----------------------------------------------------------------

pandas/tests/indexes/test_setops.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
The tests in this package are to ensure the proper resultant dtypes of
33
set operations.
44
"""
5-
import itertools as it
6-
75
import numpy as np
86
import pytest
97

@@ -13,7 +11,6 @@
1311
from pandas import Float64Index, Int64Index, RangeIndex, UInt64Index
1412
import pandas._testing as tm
1513
from pandas.api.types import pandas_dtype
16-
from pandas.conftest import indices_dict
1714

1815
COMPATIBLE_INCONSISTENT_PAIRS = {
1916
(Int64Index, RangeIndex): (tm.makeIntIndex, tm.makeRangeIndex),
@@ -23,14 +20,6 @@
2320
}
2421

2522

26-
@pytest.fixture(params=it.combinations(indices_dict, 2), ids="-".join)
27-
def index_pair(request):
28-
"""
29-
Create all combinations of 2 index types.
30-
"""
31-
return indices_dict[request.param[0]], indices_dict[request.param[1]]
32-
33-
3423
def test_union_same_types(indices):
3524
# Union with a non-unique, non-monotonic index raises error
3625
# Only needed for bool index factory
@@ -39,14 +28,15 @@ def test_union_same_types(indices):
3928
assert idx1.union(idx2).dtype == idx1.dtype
4029

4130

42-
def test_union_different_types(index_pair):
31+
def test_union_different_types(indices, index_fixture2):
32+
# This test only considers combinations of indices
4333
# GH 23525
44-
idx1, idx2 = index_pair
34+
idx1, idx2 = indices, index_fixture2
4535
type_pair = tuple(sorted([type(idx1), type(idx2)], key=lambda x: str(x)))
4636
if type_pair in COMPATIBLE_INCONSISTENT_PAIRS:
4737
pytest.xfail("This test only considers non compatible indexes.")
4838

49-
if any(isinstance(idx, pd.MultiIndex) for idx in index_pair):
39+
if any(isinstance(idx, pd.MultiIndex) for idx in (idx1, idx2)):
5040
pytest.xfail("This test doesn't consider multiindixes.")
5141

5242
if is_dtype_equal(idx1.dtype, idx2.dtype):

0 commit comments

Comments
 (0)