Skip to content

Commit 49f2779

Browse files
jbrockmendeljreback
authored andcommitted
REF/TST: collect misplaced tests (pandas-dev#31224)
1 parent 32d368b commit 49f2779

File tree

6 files changed

+35
-94
lines changed

6 files changed

+35
-94
lines changed

pandas/tests/indexes/multi/test_compat.py

-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ def test_ndarray_compat_properties(idx, compat_props):
112112
idx.values.nbytes
113113

114114

115-
def test_compat(indices):
116-
assert indices.tolist() == list(indices)
117-
118-
119115
def test_pickle_compat_construction(holder):
120116
# this is testing for pickle compat
121117
# need an object to create with

pandas/tests/indexes/multi/test_conversion.py

-11
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,6 @@ def test_roundtrip_pickle_with_tz():
142142
assert index.equal_levels(unpickled)
143143

144144

145-
def test_pickle(indices):
146-
return # FIXME: this can't be right?
147-
148-
unpickled = tm.round_trip_pickle(indices)
149-
assert indices.equals(unpickled)
150-
original_name, indices.name = indices.name, "foo"
151-
unpickled = tm.round_trip_pickle(indices)
152-
assert indices.equals(unpickled)
153-
indices.name = original_name
154-
155-
156145
def test_to_series(idx):
157146
# assert that we are creating a copy of the index
158147

pandas/tests/indexes/multi/test_integrity.py

-19
Original file line numberDiff line numberDiff line change
@@ -250,25 +250,6 @@ def test_rangeindex_fallback_coercion_bug():
250250
tm.assert_index_equal(result, expected)
251251

252252

253-
def test_hash_error(indices):
254-
index = indices
255-
with pytest.raises(TypeError, match=f"unhashable type: '{type(index).__name__}'"):
256-
hash(indices)
257-
258-
259-
def test_mutability(indices):
260-
if not len(indices):
261-
return
262-
msg = "Index does not support mutable operations"
263-
with pytest.raises(TypeError, match=msg):
264-
indices[0] = indices[0]
265-
266-
267-
def test_wrong_number_names(indices):
268-
with pytest.raises(ValueError, match="^Length"):
269-
indices.names = ["apple", "banana", "carrot"]
270-
271-
272253
def test_memory_usage(idx):
273254
result = idx.memory_usage()
274255
if len(idx):

pandas/tests/indexes/multi/test_monotonic.py

+1-55
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import numpy as np
2-
import pytest
32

43
import pandas as pd
5-
from pandas import Index, IntervalIndex, MultiIndex
6-
from pandas.api.types import is_scalar
4+
from pandas import Index, MultiIndex
75

86

97
def test_is_monotonic_increasing():
@@ -176,55 +174,3 @@ def test_is_strictly_monotonic_decreasing():
176174
)
177175
assert idx.is_monotonic_decreasing is True
178176
assert idx._is_strictly_monotonic_decreasing is False
179-
180-
181-
def test_searchsorted_monotonic(indices):
182-
# GH17271
183-
# not implemented for tuple searches in MultiIndex
184-
# or Intervals searches in IntervalIndex
185-
if isinstance(indices, (MultiIndex, IntervalIndex)):
186-
return
187-
188-
# nothing to test if the index is empty
189-
if indices.empty:
190-
return
191-
value = indices[0]
192-
193-
# determine the expected results (handle dupes for 'right')
194-
expected_left, expected_right = 0, (indices == value).argmin()
195-
if expected_right == 0:
196-
# all values are the same, expected_right should be length
197-
expected_right = len(indices)
198-
199-
# test _searchsorted_monotonic in all cases
200-
# test searchsorted only for increasing
201-
if indices.is_monotonic_increasing:
202-
ssm_left = indices._searchsorted_monotonic(value, side="left")
203-
assert is_scalar(ssm_left)
204-
assert expected_left == ssm_left
205-
206-
ssm_right = indices._searchsorted_monotonic(value, side="right")
207-
assert is_scalar(ssm_right)
208-
assert expected_right == ssm_right
209-
210-
ss_left = indices.searchsorted(value, side="left")
211-
assert is_scalar(ss_left)
212-
assert expected_left == ss_left
213-
214-
ss_right = indices.searchsorted(value, side="right")
215-
assert is_scalar(ss_right)
216-
assert expected_right == ss_right
217-
218-
elif indices.is_monotonic_decreasing:
219-
ssm_left = indices._searchsorted_monotonic(value, side="left")
220-
assert is_scalar(ssm_left)
221-
assert expected_left == ssm_left
222-
223-
ssm_right = indices._searchsorted_monotonic(value, side="right")
224-
assert is_scalar(ssm_right)
225-
assert expected_right == ssm_right
226-
227-
else:
228-
# non-monotonic should raise.
229-
with pytest.raises(ValueError):
230-
indices._searchsorted_monotonic(value, side="left")

pandas/tests/indexes/multi/test_sorting.py

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ def test_sortlevel_deterministic():
6666
assert sorted_idx.equals(expected[::-1])
6767

6868

69-
def test_sort(indices):
70-
with pytest.raises(TypeError):
71-
indices.sort()
72-
73-
7469
def test_numpy_argsort(idx):
7570
result = np.argsort(idx)
7671
expected = idx.argsort()
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Tests that can be parametrized over _any_ Index object.
3+
4+
TODO: consider using hypothesis for these.
5+
"""
6+
import pytest
7+
8+
9+
def test_sort(indices):
10+
with pytest.raises(TypeError):
11+
indices.sort()
12+
13+
14+
def test_hash_error(indices):
15+
index = indices
16+
with pytest.raises(TypeError, match=f"unhashable type: '{type(index).__name__}'"):
17+
hash(indices)
18+
19+
20+
def test_mutability(indices):
21+
if not len(indices):
22+
return
23+
msg = "Index does not support mutable operations"
24+
with pytest.raises(TypeError, match=msg):
25+
indices[0] = indices[0]
26+
27+
28+
def test_wrong_number_names(indices):
29+
with pytest.raises(ValueError, match="^Length"):
30+
indices.names = ["apple", "banana", "carrot"]
31+
32+
33+
def test_tolist_matches_list(indices):
34+
assert indices.tolist() == list(indices)

0 commit comments

Comments
 (0)