diff --git a/pandas/conftest.py b/pandas/conftest.py index 39b98ba175a15..4861082840b1d 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -416,6 +416,10 @@ def indices(request): return indices_dict[request.param].copy() +# Needed to generate cartesian product of indices +index_fixture2 = indices + + # ---------------------------------------------------------------- # Series' # ---------------------------------------------------------------- diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index d0cbb2ab75f72..818d5474eddf5 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -2,8 +2,6 @@ The tests in this package are to ensure the proper resultant dtypes of set operations. """ -import itertools as it - import numpy as np import pytest @@ -13,7 +11,6 @@ from pandas import Float64Index, Int64Index, RangeIndex, UInt64Index import pandas._testing as tm from pandas.api.types import pandas_dtype -from pandas.conftest import indices_dict COMPATIBLE_INCONSISTENT_PAIRS = { (Int64Index, RangeIndex): (tm.makeIntIndex, tm.makeRangeIndex), @@ -23,14 +20,6 @@ } -@pytest.fixture(params=it.combinations(indices_dict, 2), ids="-".join) -def index_pair(request): - """ - Create all combinations of 2 index types. - """ - return indices_dict[request.param[0]], indices_dict[request.param[1]] - - def test_union_same_types(indices): # Union with a non-unique, non-monotonic index raises error # Only needed for bool index factory @@ -39,14 +28,15 @@ def test_union_same_types(indices): assert idx1.union(idx2).dtype == idx1.dtype -def test_union_different_types(index_pair): +def test_union_different_types(indices, index_fixture2): + # This test only considers combinations of indices # GH 23525 - idx1, idx2 = index_pair + idx1, idx2 = indices, index_fixture2 type_pair = tuple(sorted([type(idx1), type(idx2)], key=lambda x: str(x))) if type_pair in COMPATIBLE_INCONSISTENT_PAIRS: pytest.xfail("This test only considers non compatible indexes.") - if any(isinstance(idx, pd.MultiIndex) for idx in index_pair): + if any(isinstance(idx, pd.MultiIndex) for idx in (idx1, idx2)): pytest.xfail("This test doesn't consider multiindixes.") if is_dtype_equal(idx1.dtype, idx2.dtype):