From 78f8370e8a62957c1da4f6d0afda88ea78738027 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Tue, 24 Mar 2020 01:38:15 +0100 Subject: [PATCH 1/3] using indices fixture in tests/indexes/test_setops.py --- pandas/conftest.py | 4 ++++ pandas/tests/indexes/test_setops.py | 17 +++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 903e1a5dec132..f827d0ecc80af 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -404,6 +404,10 @@ def indices(request): return indices_dict[request.param].copy() +# Needed to generate cartesian product of indices +indices2 = indices + + # ---------------------------------------------------------------- # Series' # ---------------------------------------------------------------- diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index d0cbb2ab75f72..80dc77e11bbb8 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,14 @@ 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, indices2): # GH 23525 - idx1, idx2 = index_pair + idx1, idx2 = indices, indices2 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): From 0749634923ba715b72a72784d59dbc660ed5c243 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Tue, 24 Mar 2020 12:52:15 +0100 Subject: [PATCH 2/3] added comment --- pandas/tests/indexes/test_setops.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index 80dc77e11bbb8..57bea4d1ada25 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -29,6 +29,7 @@ def test_union_same_types(indices): def test_union_different_types(indices, indices2): + # This test only considers combinations of indices # GH 23525 idx1, idx2 = indices, indices2 type_pair = tuple(sorted([type(idx1), type(idx2)], key=lambda x: str(x))) From 5bb42d82ccaf0f103f49a11b665ae1cff2870a25 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Tue, 24 Mar 2020 21:26:02 +0100 Subject: [PATCH 3/3] renamed duplicated fixture --- pandas/conftest.py | 2 +- pandas/tests/indexes/test_setops.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index f827d0ecc80af..d5603fc019b56 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -405,7 +405,7 @@ def indices(request): # Needed to generate cartesian product of indices -indices2 = indices +index_fixture2 = indices # ---------------------------------------------------------------- diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index 57bea4d1ada25..818d5474eddf5 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -28,10 +28,10 @@ def test_union_same_types(indices): assert idx1.union(idx2).dtype == idx1.dtype -def test_union_different_types(indices, indices2): +def test_union_different_types(indices, index_fixture2): # This test only considers combinations of indices # GH 23525 - idx1, idx2 = indices, indices2 + 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.")