Skip to content

Commit 40df396

Browse files
authored
TST: More explicit test patterns (#54463)
1 parent fa9e462 commit 40df396

32 files changed

+120
-135
lines changed

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ def test_dti_cmp_datetimelike(self, other, tz_naive_fixture):
414414
dti = date_range("2016-01-01", periods=2, tz=tz)
415415
if tz is not None:
416416
if isinstance(other, np.datetime64):
417-
# no tzaware version available
418-
return
417+
pytest.skip("no tzaware version available")
419418
other = localize_pydatetime(other, dti.tzinfo)
420419

421420
result = dti == other
@@ -1080,13 +1079,14 @@ def test_dt64arr_add_dtlike_raises(self, tz_naive_fixture, box_with_array):
10801079
@pytest.mark.parametrize("freq", ["H", "D", "W", "M", "MS", "Q", "B", None])
10811080
@pytest.mark.parametrize("dtype", [None, "uint8"])
10821081
def test_dt64arr_addsub_intlike(
1083-
self, dtype, box_with_array, freq, tz_naive_fixture
1082+
self, request, dtype, box_with_array, freq, tz_naive_fixture
10841083
):
10851084
# GH#19959, GH#19123, GH#19012
10861085
tz = tz_naive_fixture
10871086
if box_with_array is pd.DataFrame:
1088-
# alignment headaches
1089-
return
1087+
request.node.add_marker(
1088+
pytest.mark.xfail(raises=ValueError, reason="Axis alignment fails")
1089+
)
10901090

10911091
if freq is None:
10921092
dti = DatetimeIndex(["NaT", "2017-04-05 06:07:08"], tz=tz)

pandas/tests/arithmetic/test_numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def test_divmod_zero(self, zero, numeric_idx):
377377
def test_div_negative_zero(self, zero, numeric_idx, op):
378378
# Check that -1 / -0.0 returns np.inf, not -np.inf
379379
if numeric_idx.dtype == np.uint64:
380-
return
380+
pytest.skip(f"Not relevant for {numeric_idx.dtype}")
381381
idx = numeric_idx - 3
382382

383383
expected = Index([-np.inf, -np.inf, -np.inf, np.nan, np.inf], dtype=np.float64)

pandas/tests/arithmetic/test_timedelta64.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ def test_td64arr_add_sub_datetimelike_scalar(
10021002
ts = dt_scalar.to_pydatetime()
10031003
elif cls is np.datetime64:
10041004
if tz_naive_fixture is not None:
1005-
return
1005+
pytest.skip(f"{cls} doesn support {tz_naive_fixture}")
10061006
ts = dt_scalar.to_datetime64()
10071007
else:
10081008
ts = dt_scalar

pandas/tests/frame/methods/test_to_csv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,7 @@ def create_cols(name):
674674

675675
# add in some nans
676676
df_float.iloc[30:50, 1:3] = np.nan
677-
678-
# ## this is a bug in read_csv right now ####
679-
# df_dt.loc[30:50,1:3] = np.nan
680-
# FIXME: don't leave commented-out
677+
df_dt.iloc[30:50, 1:3] = np.nan
681678

682679
df = pd.concat([df_float, df_int, df_bool, df_object, df_dt], axis=1)
683680

pandas/tests/frame/test_arithmetic.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,12 @@ def test_inplace_ops_identity(self):
17661766
[
17671767
"add",
17681768
"and",
1769-
"div",
1769+
pytest.param(
1770+
"div",
1771+
marks=pytest.mark.xfail(
1772+
raises=AttributeError, reason="__idiv__ not implemented"
1773+
),
1774+
),
17701775
"floordiv",
17711776
"mod",
17721777
"mul",
@@ -1778,9 +1783,6 @@ def test_inplace_ops_identity(self):
17781783
],
17791784
)
17801785
def test_inplace_ops_identity2(self, op):
1781-
if op == "div":
1782-
return
1783-
17841786
df = DataFrame({"a": [1.0, 2.0, 3.0], "b": [1, 2, 3]})
17851787

17861788
operand = 2

pandas/tests/frame/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ def test_dict_nocopy(
25142514
b = np.array([3, 4], dtype=any_numpy_dtype)
25152515
if b.dtype.kind in ["S", "U"]:
25162516
# These get cast, making the checks below more cumbersome
2517-
return
2517+
pytest.skip(f"{b.dtype} get cast, making the checks below more cumbersome")
25182518

25192519
c = pd.array([1, 2], dtype=any_numeric_ea_dtype)
25202520
c_orig = c.copy()

pandas/tests/groupby/test_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ def test_frame_consistency(groupby_func):
205205
def test_series_consistency(request, groupby_func):
206206
# GH#48028
207207
if groupby_func in ("first", "last"):
208-
# first and last are entirely different between Series and groupby
209-
return
208+
pytest.skip("first and last are entirely different between Series and groupby")
210209

211210
if groupby_func in ("cumcount", "corrwith", "ngroup"):
212211
assert not hasattr(Series, groupby_func)

pandas/tests/groupby/transform/test_transform.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,8 @@ def frame_mi(frame):
775775
{"by": np.random.default_rng(2).integers(0, 50, size=10).astype(float)},
776776
{"level": 0},
777777
{"by": "string"},
778-
# {"by": 'string_missing'}]:
779-
# {"by": ['int','string']}]:
780-
# TODO: remove or enable commented-out code
778+
pytest.param({"by": "string_missing"}, marks=pytest.mark.xfail),
779+
{"by": ["int", "string"]},
781780
],
782781
)
783782
def test_cython_transform_frame(request, op, args, targop, df_fix, gb_target):
@@ -825,9 +824,9 @@ def test_cython_transform_frame(request, op, args, targop, df_fix, gb_target):
825824
{"by": np.random.default_rng(2).integers(0, 50, size=10).astype(float)},
826825
{"level": 0},
827826
{"by": "string"},
828-
# {"by": 'string_missing'}]:
829-
# {"by": ['int','string']}]:
830-
# TODO: remove or enable commented-out code
827+
# TODO: create xfail condition given other params
828+
# {"by": 'string_missing'},
829+
{"by": ["int", "string"]},
831830
],
832831
)
833832
@pytest.mark.parametrize(

pandas/tests/indexes/multi/test_setops.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,7 @@ def test_union_with_duplicates_keep_ea_dtype(dupe_val, any_numeric_ea_dtype):
626626
def test_union_duplicates(index, request):
627627
# GH#38977
628628
if index.empty or isinstance(index, (IntervalIndex, CategoricalIndex)):
629-
# No duplicates in empty indexes
630-
return
629+
pytest.skip(f"No duplicates in an empty {type(index).__name__}")
631630

632631
values = index.unique().values.tolist()
633632
mi1 = MultiIndex.from_arrays([values, [1] * len(values)])

pandas/tests/indexes/test_any_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_hash_error(index):
3434

3535
def test_mutability(index):
3636
if not len(index):
37-
return
37+
pytest.skip("Test doesn't make sense for empty index")
3838
msg = "Index does not support mutable operations"
3939
with pytest.raises(TypeError, match=msg):
4040
index[0] = index[0]

0 commit comments

Comments
 (0)