Skip to content

Commit d75bf39

Browse files
committed
Move aliases and add sort parameter to other union test
1 parent 15bc6fd commit d75bf39

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pandas/tests/indexes/test_range.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
from .test_numeric import Numeric
1313

14+
# aliases to make some tests easier to read
15+
RI = RangeIndex
16+
I64 = Int64Index
17+
F64 = Float64Index
18+
OI = Index
1419

1520
class TestRangeIndex(Numeric):
1621
_holder = RangeIndex
@@ -565,22 +570,20 @@ def test_intersection(self, sort):
565570
expected = RangeIndex(0, 0, 1)
566571
tm.assert_index_equal(result, expected)
567572

568-
def test_union_noncomparable(self):
573+
@pytest.mark.parametrize('sort', [False, None])
574+
def test_union_noncomparable(self, sort):
569575
from datetime import datetime, timedelta
570576
# corner case, non-Int64Index
571577
now = datetime.now()
572578
other = Index([now + timedelta(i) for i in range(4)], dtype=object)
573-
result = self.index.union(other)
579+
result = self.index.union(other, sort=sort)
574580
expected = Index(np.concatenate((self.index, other)))
575581
tm.assert_index_equal(result, expected)
576582

577-
result = other.union(self.index)
583+
result = other.union(self.index, sort=sort)
578584
expected = Index(np.concatenate((other, self.index)))
579585
tm.assert_index_equal(result, expected)
580586

581-
RI = RangeIndex
582-
I64 = Int64Index
583-
584587
@pytest.fixture(params=[
585588
(RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1)),
586589
(RI(0, 10, 1), RI(5, 20, 1), RI(0, 20, 1), I64(range(20))),
@@ -866,10 +869,6 @@ def test_len_specialised(self):
866869

867870
def test_append(self):
868871
# GH16212
869-
RI = RangeIndex
870-
I64 = Int64Index
871-
F64 = Float64Index
872-
OI = Index
873872
cases = [([RI(1, 12, 5)], RI(1, 12, 5)),
874873
([RI(0, 6, 4)], RI(0, 6, 4)),
875874
([RI(1, 3), RI(3, 7)], RI(1, 7)),

0 commit comments

Comments
 (0)