Skip to content

Commit f46df09

Browse files
authored
TST: Remove unused fixtures (#45692)
* TST: Remove unused fixtures * Undo a removed fixture * Add back other fixtures * Undo a file * Try undoing this? * Revert "Try undoing this?" This reverts commit 0e56cb0.
1 parent c44b561 commit f46df09

File tree

75 files changed

+135
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+135
-147
lines changed

pandas/tests/apply/test_str.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_with_string_args(datetime_series):
5555

5656
@pytest.mark.parametrize("op", ["mean", "median", "std", "var"])
5757
@pytest.mark.parametrize("how", ["agg", "apply"])
58-
def test_apply_np_reducer(float_frame, op, how):
58+
def test_apply_np_reducer(op, how):
5959
# GH 39116
6060
float_frame = DataFrame({"a": [1, 2], "b": [3, 4]})
6161
result = getattr(float_frame, how)(op)

pandas/tests/arrays/categorical/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class TestCategorical:
5-
def setup_method(self, method):
5+
def setup_method(self):
66
self.factor = Categorical(
77
["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True
88
)

pandas/tests/arrays/categorical/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def array(self, dtype=None):
370370
yield
371371

372372

373-
def test_series_at(non_coercible_categorical):
373+
def test_series_at():
374374
arr = Categorical(["a", "b", "c"])
375375
ser = Series(arr)
376376
result = ser.at[0]

pandas/tests/arrays/masked/test_arithmetic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_error_len_mismatch(data, all_arithmetic_operators):
173173

174174

175175
@pytest.mark.parametrize("op", ["__neg__", "__abs__", "__invert__"])
176-
def test_unary_op_does_not_propagate_mask(data, op, request):
176+
def test_unary_op_does_not_propagate_mask(data, op):
177177
# https://github.com/pandas-dev/pandas/issues/39943
178178
data, _ = data
179179
ser = pd.Series(data)

pandas/tests/arrays/sparse/test_array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class TestSparseArray:
20-
def setup_method(self, method):
20+
def setup_method(self):
2121
self.arr_data = np.array([np.nan, np.nan, 1, 2, 3, np.nan, 4, 5, np.nan, 6])
2222
self.arr = SparseArray(self.arr_data)
2323
self.zarr = SparseArray([0, 0, 1, 2, 3, 0, 4, 5, 0, 6], fill_value=0)

pandas/tests/arrays/string_/test_string.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def test_to_numpy_na_value(dtype, nulls_fixture):
554554
tm.assert_numpy_array_equal(result, expected)
555555

556556

557-
def test_isin(dtype, request, fixed_now_ts):
557+
def test_isin(dtype, fixed_now_ts):
558558
s = pd.Series(["a", "b", None], dtype=dtype)
559559

560560
result = s.isin(["a", "c"])

pandas/tests/config/test_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def setup_class(cls):
1818
cls.do = deepcopy(getattr(cls.cf, "_deprecated_options"))
1919
cls.ro = deepcopy(getattr(cls.cf, "_registered_options"))
2020

21-
def setup_method(self, method):
21+
def setup_method(self):
2222
setattr(self.cf, "_global_config", {})
2323
setattr(self.cf, "options", self.cf.DictWrapper(self.cf._global_config))
2424
setattr(self.cf, "_deprecated_options", {})
@@ -30,7 +30,7 @@ def setup_method(self, method):
3030
# "chained_assignment" option, so re-register it.
3131
self.cf.register_option("chained_assignment", "raise")
3232

33-
def teardown_method(self, method):
33+
def teardown_method(self):
3434
setattr(self.cf, "_global_config", self.gc)
3535
setattr(self.cf, "_deprecated_options", self.do)
3636
setattr(self.cf, "_registered_options", self.ro)

pandas/tests/dtypes/cast/test_promote.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def test_maybe_promote_bytes_with_any(bytes_dtype, any_numpy_dtype_reduced):
348348
_check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar)
349349

350350

351-
def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced, bytes_dtype):
351+
def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced):
352352
dtype = np.dtype(any_numpy_dtype_reduced)
353353

354354
# create array of given dtype
@@ -391,9 +391,7 @@ def test_maybe_promote_datetime64_with_any(datetime64_dtype, any_numpy_dtype_red
391391
],
392392
ids=["pd.Timestamp", "np.datetime64", "datetime.datetime", "datetime.date"],
393393
)
394-
def test_maybe_promote_any_with_datetime64(
395-
any_numpy_dtype_reduced, datetime64_dtype, fill_value
396-
):
394+
def test_maybe_promote_any_with_datetime64(any_numpy_dtype_reduced, fill_value):
397395
dtype = np.dtype(any_numpy_dtype_reduced)
398396

399397
# filling datetime with anything but datetime casts to object
@@ -465,9 +463,7 @@ def test_maybe_promote_timedelta64_with_any(timedelta64_dtype, any_numpy_dtype_r
465463
[pd.Timedelta(days=1), np.timedelta64(24, "h"), datetime.timedelta(1)],
466464
ids=["pd.Timedelta", "np.timedelta64", "datetime.timedelta"],
467465
)
468-
def test_maybe_promote_any_with_timedelta64(
469-
any_numpy_dtype_reduced, timedelta64_dtype, fill_value
470-
):
466+
def test_maybe_promote_any_with_timedelta64(any_numpy_dtype_reduced, fill_value):
471467
dtype = np.dtype(any_numpy_dtype_reduced)
472468

473469
# filling anything but timedelta with timedelta casts to object
@@ -496,7 +492,7 @@ def test_maybe_promote_string_with_any(string_dtype, any_numpy_dtype_reduced):
496492
_check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar)
497493

498494

499-
def test_maybe_promote_any_with_string(any_numpy_dtype_reduced, string_dtype):
495+
def test_maybe_promote_any_with_string(any_numpy_dtype_reduced):
500496
dtype = np.dtype(any_numpy_dtype_reduced)
501497

502498
# create array of given dtype
@@ -523,7 +519,7 @@ def test_maybe_promote_object_with_any(object_dtype, any_numpy_dtype_reduced):
523519
_check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar)
524520

525521

526-
def test_maybe_promote_any_with_object(any_numpy_dtype_reduced, object_dtype):
522+
def test_maybe_promote_any_with_object(any_numpy_dtype_reduced):
527523
dtype = np.dtype(any_numpy_dtype_reduced)
528524

529525
# create array of object dtype from a scalar value (i.e. passing

pandas/tests/dtypes/test_dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ def test_categories(self):
848848
tm.assert_index_equal(result.categories, pd.Index(["a", "b", "c"]))
849849
assert result.ordered is False
850850

851-
def test_equal_but_different(self, ordered):
851+
def test_equal_but_different(self):
852852
c1 = CategoricalDtype([1, 2, 3])
853853
c2 = CategoricalDtype([1.0, 2.0, 3.0])
854854
assert c1 is not c2

pandas/tests/extension/base/setitem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def test_setitem_series(self, data, full_indexer):
357357
)
358358
self.assert_series_equal(result, expected)
359359

360-
def test_setitem_frame_2d_values(self, data, request):
360+
def test_setitem_frame_2d_values(self, data):
361361
# GH#44514
362362
df = pd.DataFrame({"A": data})
363363
orig = df.copy()

pandas/tests/extension/test_sparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def data(request):
5454

5555

5656
@pytest.fixture
57-
def data_for_twos(request):
57+
def data_for_twos():
5858
return SparseArray(np.ones(100) * 2)
5959

6060

pandas/tests/frame/indexing/test_setitem.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def test_setitem_frame_length_0_str_key(self, indexer):
397397
expected["A"] = expected["A"].astype("object")
398398
tm.assert_frame_equal(df, expected)
399399

400-
def test_setitem_frame_duplicate_columns(self, using_array_manager, request):
400+
def test_setitem_frame_duplicate_columns(self, using_array_manager):
401401
# GH#15695
402402
cols = ["A", "B", "C"] * 2
403403
df = DataFrame(index=range(3), columns=cols)
@@ -1099,7 +1099,7 @@ def test_setitem_duplicate_columns_not_inplace(self):
10991099
@pytest.mark.parametrize(
11001100
"value", [1, np.array([[1], [1]], dtype="int64"), [[1], [1]]]
11011101
)
1102-
def test_setitem_same_dtype_not_inplace(self, value, using_array_manager, request):
1102+
def test_setitem_same_dtype_not_inplace(self, value, using_array_manager):
11031103
# GH#39510
11041104
cols = ["A", "B"]
11051105
df = DataFrame(0, index=[0, 1], columns=cols)

pandas/tests/frame/methods/test_interpolate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_interp_ignore_all_good(self):
320320
result = df[["B", "D"]].interpolate(downcast=None)
321321
tm.assert_frame_equal(result, df[["B", "D"]])
322322

323-
def test_interp_time_inplace_axis(self, axis):
323+
def test_interp_time_inplace_axis(self):
324324
# GH 9687
325325
periods = 5
326326
idx = date_range(start="2014-01-01", periods=periods)

pandas/tests/frame/methods/test_quantile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def test_quantile_ea_with_na(self, obj, index):
673673

674674
# TODO(GH#39763): filtering can be removed after GH#39763 is fixed
675675
@pytest.mark.filterwarnings("ignore:Using .astype to convert:FutureWarning")
676-
def test_quantile_ea_all_na(self, obj, index, frame_or_series, request):
676+
def test_quantile_ea_all_na(self, obj, index):
677677
obj.iloc[:] = index._na_value
678678

679679
# TODO(ArrayManager): this casting should be unnecessary after GH#39763 is fixed

pandas/tests/frame/methods/test_tz_convert.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ def test_tz_convert_and_localize(self, fn):
104104
# Not DatetimeIndex / PeriodIndex
105105
with pytest.raises(TypeError, match="DatetimeIndex"):
106106
df = DataFrame(index=int_idx)
107-
df = getattr(df, fn)("US/Pacific")
107+
getattr(df, fn)("US/Pacific")
108108

109109
# Not DatetimeIndex / PeriodIndex
110110
with pytest.raises(TypeError, match="DatetimeIndex"):
111111
df = DataFrame(np.ones(5), MultiIndex.from_arrays([int_idx, l0]))
112-
df = getattr(df, fn)("US/Pacific", level=0)
112+
getattr(df, fn)("US/Pacific", level=0)
113113

114114
# Invalid level
115115
with pytest.raises(ValueError, match="not valid"):
116116
df = DataFrame(index=l0)
117-
df = getattr(df, fn)("US/Pacific", level=1)
117+
getattr(df, fn)("US/Pacific", level=1)
118118

119119
@pytest.mark.parametrize("copy", [True, False])
120120
def test_tz_convert_copy_inplace_mutate(self, copy, frame_or_series):

pandas/tests/frame/test_query_eval.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def skip_if_no_pandas_parser(parser):
3636

3737

3838
class TestCompat:
39-
def setup_method(self, method):
39+
def setup_method(self):
4040
self.df = DataFrame({"A": [1, 2, 3]})
4141
self.expected1 = self.df[self.df.A > 0]
4242
self.expected2 = self.df.A + 1
@@ -1090,10 +1090,10 @@ def test_query_string_scalar_variable(self, parser, engine):
10901090

10911091

10921092
class TestDataFrameEvalWithFrame:
1093-
def setup_method(self, method):
1093+
def setup_method(self):
10941094
self.frame = DataFrame(np.random.randn(10, 3), columns=list("abc"))
10951095

1096-
def teardown_method(self, method):
1096+
def teardown_method(self):
10971097
del self.frame
10981098

10991099
def test_simple_expr(self, parser, engine):

pandas/tests/frame/test_repr_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_assign_index_sequences(self):
6262
df.index = index
6363
repr(df)
6464

65-
def test_repr_with_mi_nat(self, float_string_frame):
65+
def test_repr_with_mi_nat(self):
6666
df = DataFrame({"X": [1, 2]}, index=[[NaT, Timestamp("20130101")], ["a", "b"]])
6767
result = repr(df)
6868
expected = " X\nNaT a 1\n2013-01-01 b 2"

pandas/tests/frame/test_ufunc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_binary_input_dispatch_binop(dtype):
8181
),
8282
],
8383
)
84-
def test_ufunc_passes_args(func, arg, expected, request):
84+
def test_ufunc_passes_args(func, arg, expected):
8585
# GH#40662
8686
arr = np.array([[1, 2], [3, 4]])
8787
df = pd.DataFrame(arr)

pandas/tests/groupby/test_apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_apply_with_mixed_dtype():
241241
tm.assert_series_equal(result1, result2)
242242

243243

244-
def test_groupby_as_index_apply(df):
244+
def test_groupby_as_index_apply():
245245
# GH #4648 and #3417
246246
df = DataFrame(
247247
{

pandas/tests/groupby/test_categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ def test_dataframe_groupby_on_2_categoricals_when_observed_is_true(reduction_fun
14471447

14481448
@pytest.mark.parametrize("observed", [False, None])
14491449
def test_dataframe_groupby_on_2_categoricals_when_observed_is_false(
1450-
reduction_func, observed, request
1450+
reduction_func, observed
14511451
):
14521452
# GH 23865
14531453
# GH 27075

pandas/tests/groupby/test_groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ def test_groupby_as_index_corner(df, ts):
821821
df.groupby(lambda x: x.lower(), as_index=False, axis=1)
822822

823823

824-
def test_groupby_multiple_key(df):
824+
def test_groupby_multiple_key():
825825
df = tm.makeTimeDataFrame()
826826
grouped = df.groupby([lambda x: x.year, lambda x: x.month, lambda x: x.day])
827827
agged = grouped.sum()

pandas/tests/groupby/test_size.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_size(df, by):
2020

2121
@pytest.mark.parametrize("by", ["A", "B", ["A", "B"]])
2222
@pytest.mark.parametrize("sort", [True, False])
23-
def test_size_sort(df, sort, by):
23+
def test_size_sort(sort, by):
2424
df = DataFrame(np.random.choice(20, (1000, 3)), columns=list("ABC"))
2525
left = df.groupby(by=by, sort=sort).size()
2626
right = df.groupby(by=by, sort=sort)["C"].apply(lambda a: a.shape[0])

pandas/tests/indexes/categorical/test_category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def simple_index(self) -> CategoricalIndex:
2525
return self._index_cls(list("aabbca"), categories=list("cab"), ordered=False)
2626

2727
@pytest.fixture
28-
def index(self, request):
28+
def index(self):
2929
return tm.makeCategoricalIndex(100)
3030

3131
def create_index(self, *, categories=None, ordered=False):

pandas/tests/indexes/datetimes/test_setops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def test_intersection_non_tick_no_fastpath(self):
417417

418418

419419
class TestBusinessDatetimeIndex:
420-
def setup_method(self, method):
420+
def setup_method(self):
421421
self.rng = bdate_range(START, END)
422422

423423
def test_union(self, sort):
@@ -555,7 +555,7 @@ def test_intersection_duplicates(self, sort):
555555

556556

557557
class TestCustomDatetimeIndex:
558-
def setup_method(self, method):
558+
def setup_method(self):
559559
self.rng = bdate_range(START, END, freq="C")
560560

561561
def test_union(self, sort):

pandas/tests/indexes/multi/test_setops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def test_union_sort_other_empty(slice_):
368368

369369

370370
@pytest.mark.xfail(reason="Not implemented.")
371-
def test_union_sort_other_empty_sort(slice_):
371+
def test_union_sort_other_empty_sort():
372372
# TODO(GH#25151): decide on True behaviour
373373
# # sort=True
374374
idx = MultiIndex.from_product([[1, 0], ["a", "b"]])

pandas/tests/indexes/test_base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def test_empty_fancy_raises(self, index):
452452
with pytest.raises(IndexError, match=msg):
453453
index[empty_farr]
454454

455-
def test_union_dt_as_obj(self, sort, simple_index):
455+
def test_union_dt_as_obj(self, simple_index):
456456
# TODO: Replace with fixturesult
457457
index = simple_index
458458
date_index = date_range("2019-01-01", periods=10)
@@ -792,7 +792,7 @@ def test_isin(self, values, index, expected):
792792
result = index.isin(values)
793793
tm.assert_numpy_array_equal(result, expected)
794794

795-
def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
795+
def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
796796
# Test cartesian product of null fixtures and ensure that we don't
797797
# mangle the various types (save a corner case with PyPy)
798798

@@ -820,7 +820,7 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
820820
np.array([False, False]),
821821
)
822822

823-
def test_isin_nan_common_float64(self, request, nulls_fixture):
823+
def test_isin_nan_common_float64(self, nulls_fixture):
824824

825825
if nulls_fixture is pd.NaT or nulls_fixture is pd.NA:
826826
# Check 1) that we cannot construct a Float64Index with this value

pandas/tests/indexes/test_numpy_compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_numpy_ufuncs_basic(index, func):
9696
@pytest.mark.parametrize(
9797
"func", [np.isfinite, np.isinf, np.isnan, np.signbit], ids=lambda x: x.__name__
9898
)
99-
def test_numpy_ufuncs_other(index, func, request):
99+
def test_numpy_ufuncs_other(index, func):
100100
# test ufuncs of numpy, see:
101101
# https://numpy.org/doc/stable/reference/ufuncs.html
102102
if isinstance(index, (DatetimeIndex, TimedeltaIndex)):

pandas/tests/indexes/test_setops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def test_difference_preserves_type_empty(self, index, sort):
432432
expected = index[:0]
433433
tm.assert_index_equal(result, expected, exact=True)
434434

435-
def test_difference_name_retention_equals(self, index, sort, names):
435+
def test_difference_name_retention_equals(self, index, names):
436436
if isinstance(index, MultiIndex):
437437
names = [[x] * index.nlevels for x in names]
438438
index = index.rename(names[0])

pandas/tests/indexing/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Base:
4343
"multi",
4444
}
4545

46-
def setup_method(self, method):
46+
def setup_method(self):
4747

4848
self.series_ints = Series(np.random.rand(4), index=np.arange(0, 8, 2))
4949
self.frame_ints = DataFrame(

pandas/tests/indexing/multiindex/test_sorted.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_frame_getitem_not_sorted2(self, key):
6464
assert result.index.is_monotonic_increasing
6565
tm.assert_frame_equal(result, expected)
6666

67-
def test_sort_values_key(self, multiindex_dataframe_random_data):
67+
def test_sort_values_key(self):
6868
arrays = [
6969
["bar", "bar", "baz", "baz", "qux", "qux", "foo", "foo"],
7070
["one", "two", "one", "two", "one", "two", "one", "two"],

pandas/tests/indexing/test_categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
class TestCategoricalIndex:
24-
def setup_method(self, method):
24+
def setup_method(self):
2525

2626
self.df = DataFrame(
2727
{

pandas/tests/indexing/test_coercion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_insert_index_float64(self, insert, coerced_val, coerced_dtype):
265265
"insert_value",
266266
[pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
267267
)
268-
def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):
268+
def test_insert_index_datetimes(self, fill_val, exp_dtype, insert_value):
269269

270270
obj = pd.DatetimeIndex(
271271
["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz

0 commit comments

Comments
 (0)