Skip to content

Commit 86064ff

Browse files
authored
TST: skip fewer tests (#44918)
1 parent 28f4942 commit 86064ff

File tree

15 files changed

+66
-63
lines changed

15 files changed

+66
-63
lines changed

ci/deps/actions-38-db.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- pytest-cov>=2.10.1 # this is only needed in the coverage build, ref: GH 35737
1313

1414
# pandas dependencies
15-
- aiobotocore<2.0.0
15+
- aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild
1616
- beautifulsoup4
1717
- boto3
1818
- botocore>=1.11

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ dependencies:
105105

106106
- pytables>=3.6.1 # pandas.read_hdf, DataFrame.to_hdf
107107
- s3fs>=0.4.0 # file IO when using 's3://...' path
108-
- aiobotocore<2.0.0
108+
- aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild
109109
- fsspec>=0.7.4 # for generic remote file operations
110110
- gcsfs>=0.6.0 # file IO when using 'gcs://...' path
111111
- sqlalchemy # pandas.read_sql, DataFrame.to_sql

pandas/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,21 @@ def index_flat(request):
559559
index_flat2 = index_flat
560560

561561

562+
@pytest.fixture(
563+
params=[
564+
key
565+
for key in indices_dict
566+
if not isinstance(indices_dict[key], MultiIndex) and indices_dict[key].is_unique
567+
]
568+
)
569+
def index_flat_unique(request):
570+
"""
571+
index_flat with uniqueness requirement.
572+
"""
573+
key = request.param
574+
return indices_dict[key].copy()
575+
576+
562577
@pytest.fixture(
563578
params=[
564579
key

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ def describe(self):
23772377

23782378
return result
23792379

2380-
def isin(self, values) -> np.ndarray:
2380+
def isin(self, values) -> npt.NDArray[np.bool_]:
23812381
"""
23822382
Check whether `values` are contained in Categorical.
23832383
@@ -2394,7 +2394,7 @@ def isin(self, values) -> np.ndarray:
23942394
23952395
Returns
23962396
-------
2397-
isin : numpy.ndarray (bool dtype)
2397+
np.ndarray[bool]
23982398
23992399
Raises
24002400
------

pandas/tests/base/test_fillna.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
import numpy as np
77
import pytest
88

9-
from pandas.core.dtypes.generic import ABCMultiIndex
10-
11-
from pandas import Index
9+
from pandas import MultiIndex
1210
import pandas._testing as tm
1311
from pandas.tests.base.common import allow_na_ops
1412

1513

1614
def test_fillna(index_or_series_obj):
1715
# GH 11343
1816
obj = index_or_series_obj
19-
if isinstance(obj, ABCMultiIndex):
20-
pytest.skip("MultiIndex doesn't support isna")
17+
18+
if isinstance(obj, MultiIndex):
19+
msg = "isna is not defined for MultiIndex"
20+
with pytest.raises(NotImplementedError, match=msg):
21+
obj.fillna(0)
22+
return
2123

2224
# values will not be changed
2325
fill_value = obj.values[0] if len(obj) > 0 else 0
2426
result = obj.fillna(fill_value)
25-
if isinstance(obj, Index):
26-
tm.assert_index_equal(obj, result)
27-
else:
28-
tm.assert_series_equal(obj, result)
27+
28+
tm.assert_equal(obj, result)
2929

3030
# check shallow_copied
3131
assert obj is not result
@@ -41,7 +41,7 @@ def test_fillna_null(null_obj, index_or_series_obj):
4141
pytest.skip(f"{klass} doesn't allow for NA operations")
4242
elif len(obj) < 1:
4343
pytest.skip("Test doesn't make sense on empty data")
44-
elif isinstance(obj, ABCMultiIndex):
44+
elif isinstance(obj, MultiIndex):
4545
pytest.skip(f"MultiIndex can't hold '{null_obj}'")
4646

4747
values = obj._values

pandas/tests/base/test_unique.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ def test_unique_bad_unicode(index_or_series):
123123
@pytest.mark.parametrize("dropna", [True, False])
124124
def test_nunique_dropna(dropna):
125125
# GH37566
126-
s = pd.Series(["yes", "yes", pd.NA, np.nan, None, pd.NaT])
127-
res = s.nunique(dropna)
126+
ser = pd.Series(["yes", "yes", pd.NA, np.nan, None, pd.NaT])
127+
res = ser.nunique(dropna)
128128
assert res == 1 if dropna else 5

pandas/tests/extension/base/dim2.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ def test_fillna_2d_method(self, data_missing, method):
150150
self.assert_extension_array_equal(result, expected)
151151

152152
@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
153-
def test_reductions_2d_axis_none(self, data, method, request):
154-
if not hasattr(data, method):
155-
pytest.skip("test is not applicable for this type/dtype")
156-
153+
def test_reductions_2d_axis_none(self, data, method):
157154
arr2d = data.reshape(1, -1)
158155

159156
err_expected = None
@@ -178,10 +175,7 @@ def test_reductions_2d_axis_none(self, data, method, request):
178175
assert is_matching_na(result, expected) or result == expected
179176

180177
@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
181-
def test_reductions_2d_axis0(self, data, method, request):
182-
if not hasattr(data, method):
183-
pytest.skip("test is not applicable for this type/dtype")
184-
178+
def test_reductions_2d_axis0(self, data, method):
185179
arr2d = data.reshape(1, -1)
186180

187181
kwargs = {}
@@ -231,10 +225,7 @@ def get_reduction_result_dtype(dtype):
231225
# punt on method == "var"
232226

233227
@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
234-
def test_reductions_2d_axis1(self, data, method, request):
235-
if not hasattr(data, method):
236-
pytest.skip("test is not applicable for this type/dtype")
237-
228+
def test_reductions_2d_axis1(self, data, method):
238229
arr2d = data.reshape(1, -1)
239230

240231
try:

pandas/tests/indexes/test_common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,17 @@ def test_unique(self, index_flat):
244244
result = i.unique()
245245
tm.assert_index_equal(result, expected)
246246

247-
def test_searchsorted_monotonic(self, index_flat):
247+
def test_searchsorted_monotonic(self, index_flat, request):
248248
# GH17271
249249
index = index_flat
250250
# not implemented for tuple searches in MultiIndex
251251
# or Intervals searches in IntervalIndex
252252
if isinstance(index, pd.IntervalIndex):
253-
pytest.skip("Skip check for MultiIndex/IntervalIndex")
253+
mark = pytest.mark.xfail(
254+
reason="IntervalIndex.searchsorted does not support Interval arg",
255+
raises=NotImplementedError,
256+
)
257+
request.node.add_marker(mark)
254258

255259
# nothing to test if the index is empty
256260
if index.empty:

pandas/tests/indexes/test_setops.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,11 @@ def test_symmetric_difference(self, index):
272272
(None, None, None),
273273
],
274274
)
275-
def test_corner_union(self, index_flat, fname, sname, expected_name):
275+
def test_corner_union(self, index_flat_unique, fname, sname, expected_name):
276276
# GH#9943, GH#9862
277277
# Test unions with various name combinations
278278
# Do not test MultiIndex or repeats
279-
index = index_flat
280-
if not index.is_unique:
281-
pytest.skip("Not for MultiIndex or repeated indices")
279+
index = index_flat_unique
282280

283281
# Test copy.union(copy)
284282
first = index.copy().set_names(fname)
@@ -318,10 +316,8 @@ def test_corner_union(self, index_flat, fname, sname, expected_name):
318316
(None, None, None),
319317
],
320318
)
321-
def test_union_unequal(self, index_flat, fname, sname, expected_name):
322-
index = index_flat
323-
if not index.is_unique:
324-
pytest.skip("Not for MultiIndex or repeated indices")
319+
def test_union_unequal(self, index_flat_unique, fname, sname, expected_name):
320+
index = index_flat_unique
325321

326322
# test copy.union(subset) - need sort for unicode and string
327323
first = index.copy().set_names(fname)
@@ -340,12 +336,10 @@ def test_union_unequal(self, index_flat, fname, sname, expected_name):
340336
(None, None, None),
341337
],
342338
)
343-
def test_corner_intersect(self, index_flat, fname, sname, expected_name):
339+
def test_corner_intersect(self, index_flat_unique, fname, sname, expected_name):
344340
# GH#35847
345341
# Test intersections with various name combinations
346-
index = index_flat
347-
if not index.is_unique:
348-
pytest.skip("Not for MultiIndex or repeated indices")
342+
index = index_flat_unique
349343

350344
# Test copy.intersection(copy)
351345
first = index.copy().set_names(fname)
@@ -385,10 +379,8 @@ def test_corner_intersect(self, index_flat, fname, sname, expected_name):
385379
(None, None, None),
386380
],
387381
)
388-
def test_intersect_unequal(self, index_flat, fname, sname, expected_name):
389-
index = index_flat
390-
if not index.is_unique:
391-
pytest.skip("Not for MultiIndex or repeated indices")
382+
def test_intersect_unequal(self, index_flat_unique, fname, sname, expected_name):
383+
index = index_flat_unique
392384

393385
# test copy.intersection(subset) - need sort for unicode and string
394386
first = index.copy().set_names(fname)

pandas/tests/io/excel/test_writers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,18 @@ def test_read_excel_multiindex_empty_level(self, ext):
207207
@pytest.mark.parametrize("c_idx_levels", [1, 3])
208208
@pytest.mark.parametrize("r_idx_levels", [1, 3])
209209
def test_excel_multindex_roundtrip(
210-
self, ext, c_idx_names, r_idx_names, c_idx_levels, r_idx_levels
210+
self, ext, c_idx_names, r_idx_names, c_idx_levels, r_idx_levels, request
211211
):
212212
# see gh-4679
213213
with tm.ensure_clean(ext) as pth:
214-
if c_idx_levels == 1 and c_idx_names:
215-
pytest.skip(
216-
"Column index name cannot be serialized unless it's a MultiIndex"
214+
if (c_idx_levels == 1 and c_idx_names) and not (
215+
r_idx_levels == 3 and not r_idx_names
216+
):
217+
mark = pytest.mark.xfail(
218+
reason="Column index name cannot be serialized unless "
219+
"it's a MultiIndex"
217220
)
221+
request.node.add_marker(mark)
218222

219223
# Empty name case current read in as
220224
# unnamed levels, not Nones.

pandas/tests/io/formats/test_to_csv.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,6 @@ def test_to_csv_compression(self, compression_only, read_infer, to_infer):
498498
# see gh-15008
499499
compression = compression_only
500500

501-
if compression == "zip":
502-
pytest.skip(f"{compression} is not supported for to_csv")
503-
504501
# We'll complete file extension subsequently.
505502
filename = "test."
506503

pandas/tests/io/json/test_compression.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ def test_to_json_compression(compression_only, read_infer, to_infer):
9595
# see gh-15008
9696
compression = compression_only
9797

98-
if compression == "zip":
99-
pytest.skip(f"{compression} is not supported for to_csv")
100-
10198
# We'll complete file extension subsequently.
10299
filename = "test."
103100

pandas/tests/io/json/test_pandas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,10 +1323,9 @@ def test_to_jsonl(self):
13231323
tm.assert_frame_equal(read_json(result, lines=True), df)
13241324

13251325
# TODO: there is a near-identical test for pytables; can we share?
1326+
@pytest.mark.xfail(reason="GH#13774 encoding kwarg not supported", raises=TypeError)
13261327
def test_latin_encoding(self):
13271328
# GH 13774
1328-
pytest.skip("encoding not implemented in .to_json(), xref #13774")
1329-
13301329
values = [
13311330
[b"E\xc9, 17", b"", b"a", b"b", b"c"],
13321331
[b"E\xc9, 17", b"a", b"b", b"c"],

pandas/tests/series/methods/test_rank.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class TestSeriesRank:
3333
"dense": np.array([1, 3, 4, 2, np.nan, 2, 1, 5, np.nan, 3]),
3434
}
3535

36+
@td.skip_if_no_scipy
3637
def test_rank(self, datetime_series):
37-
pytest.importorskip("scipy.stats.special")
38-
rankdata = pytest.importorskip("scipy.stats.rankdata")
38+
from scipy.stats import rankdata
3939

4040
datetime_series[::2] = np.nan
4141
datetime_series[:10][::3] = 4.0
@@ -280,9 +280,9 @@ def test_rank_desc_mix_nans_infs(self):
280280
exp = Series([3, np.nan, 1, 4, 2], dtype="float64")
281281
tm.assert_series_equal(result, exp)
282282

283+
@td.skip_if_no_scipy
283284
def test_rank_methods_series(self):
284-
pytest.importorskip("scipy.stats.special")
285-
rankdata = pytest.importorskip("scipy.stats.rankdata")
285+
from scipy.stats import rankdata
286286

287287
xs = np.random.randn(9)
288288
xs = np.concatenate([xs[i:] for i in range(0, 9, 2)]) # add duplicates

pandas/tests/test_algos.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ def test_on_index_object(self):
509509
def test_dtype_preservation(self, any_numpy_dtype):
510510
# GH 15442
511511
if any_numpy_dtype in (tm.BYTES_DTYPES + tm.STRING_DTYPES):
512-
pytest.skip("skip string dtype")
512+
data = [1, 2, 2]
513+
uniques = [1, 2]
513514
elif is_integer_dtype(any_numpy_dtype):
514515
data = [1, 2, 2]
515516
uniques = [1, 2]
@@ -533,6 +534,9 @@ def test_dtype_preservation(self, any_numpy_dtype):
533534
result = Series(data, dtype=any_numpy_dtype).unique()
534535
expected = np.array(uniques, dtype=any_numpy_dtype)
535536

537+
if any_numpy_dtype in tm.STRING_DTYPES:
538+
expected = expected.astype(object)
539+
536540
tm.assert_numpy_array_equal(result, expected)
537541

538542
def test_datetime64_dtype_array_returned(self):

0 commit comments

Comments
 (0)