Skip to content

TST: Use indices fixture in tests/indexes/test_setops.py #32964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ def indices(request):
return indices_dict[request.param].copy()


# Needed to generate cartesian product of indices
indices2 = indices


# ----------------------------------------------------------------
# Series'
# ----------------------------------------------------------------
Expand Down
17 changes: 3 additions & 14 deletions pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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),
Expand All @@ -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
Expand All @@ -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):
Expand Down