Skip to content

TST: Remove unused fixtures #45692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 30, 2022
2 changes: 1 addition & 1 deletion pandas/tests/apply/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_with_string_args(datetime_series):

@pytest.mark.parametrize("op", ["mean", "median", "std", "var"])
@pytest.mark.parametrize("how", ["agg", "apply"])
def test_apply_np_reducer(float_frame, op, how):
def test_apply_np_reducer(op, how):
# GH 39116
float_frame = DataFrame({"a": [1, 2], "b": [3, 4]})
result = getattr(float_frame, how)(op)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/categorical/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class TestCategorical:
def setup_method(self, method):
def setup_method(self):
self.factor = Categorical(
["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True
)
2 changes: 1 addition & 1 deletion pandas/tests/arrays/categorical/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def array(self, dtype=None):
yield


def test_series_at(non_coercible_categorical):
def test_series_at():
arr = Categorical(["a", "b", "c"])
ser = Series(arr)
result = ser.at[0]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/masked/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_error_len_mismatch(data, all_arithmetic_operators):


@pytest.mark.parametrize("op", ["__neg__", "__abs__", "__invert__"])
def test_unary_op_does_not_propagate_mask(data, op, request):
def test_unary_op_does_not_propagate_mask(data, op):
# https://github.com/pandas-dev/pandas/issues/39943
data, _ = data
ser = pd.Series(data)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/sparse/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class TestSparseArray:
def setup_method(self, method):
def setup_method(self):
self.arr_data = np.array([np.nan, np.nan, 1, 2, 3, np.nan, 4, 5, np.nan, 6])
self.arr = SparseArray(self.arr_data)
self.zarr = SparseArray([0, 0, 1, 2, 3, 0, 4, 5, 0, 6], fill_value=0)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def test_to_numpy_na_value(dtype, nulls_fixture):
tm.assert_numpy_array_equal(result, expected)


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

result = s.isin(["a", "c"])
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup_class(cls):
cls.do = deepcopy(getattr(cls.cf, "_deprecated_options"))
cls.ro = deepcopy(getattr(cls.cf, "_registered_options"))

def setup_method(self, method):
def setup_method(self):
setattr(self.cf, "_global_config", {})
setattr(self.cf, "options", self.cf.DictWrapper(self.cf._global_config))
setattr(self.cf, "_deprecated_options", {})
Expand All @@ -30,7 +30,7 @@ def setup_method(self, method):
# "chained_assignment" option, so re-register it.
self.cf.register_option("chained_assignment", "raise")

def teardown_method(self, method):
def teardown_method(self):
setattr(self.cf, "_global_config", self.gc)
setattr(self.cf, "_deprecated_options", self.do)
setattr(self.cf, "_registered_options", self.ro)
Expand Down
14 changes: 5 additions & 9 deletions pandas/tests/dtypes/cast/test_promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def test_maybe_promote_bytes_with_any(bytes_dtype, any_numpy_dtype_reduced):
_check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar)


def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced, bytes_dtype):
def test_maybe_promote_any_with_bytes(any_numpy_dtype_reduced):
dtype = np.dtype(any_numpy_dtype_reduced)

# create array of given dtype
Expand Down Expand Up @@ -391,9 +391,7 @@ def test_maybe_promote_datetime64_with_any(datetime64_dtype, any_numpy_dtype_red
],
ids=["pd.Timestamp", "np.datetime64", "datetime.datetime", "datetime.date"],
)
def test_maybe_promote_any_with_datetime64(
any_numpy_dtype_reduced, datetime64_dtype, fill_value
):
def test_maybe_promote_any_with_datetime64(any_numpy_dtype_reduced, fill_value):
dtype = np.dtype(any_numpy_dtype_reduced)

# filling datetime with anything but datetime casts to object
Expand Down Expand Up @@ -465,9 +463,7 @@ def test_maybe_promote_timedelta64_with_any(timedelta64_dtype, any_numpy_dtype_r
[pd.Timedelta(days=1), np.timedelta64(24, "h"), datetime.timedelta(1)],
ids=["pd.Timedelta", "np.timedelta64", "datetime.timedelta"],
)
def test_maybe_promote_any_with_timedelta64(
any_numpy_dtype_reduced, timedelta64_dtype, fill_value
):
def test_maybe_promote_any_with_timedelta64(any_numpy_dtype_reduced, fill_value):
dtype = np.dtype(any_numpy_dtype_reduced)

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


def test_maybe_promote_any_with_string(any_numpy_dtype_reduced, string_dtype):
def test_maybe_promote_any_with_string(any_numpy_dtype_reduced):
dtype = np.dtype(any_numpy_dtype_reduced)

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


def test_maybe_promote_any_with_object(any_numpy_dtype_reduced, object_dtype):
def test_maybe_promote_any_with_object(any_numpy_dtype_reduced):
dtype = np.dtype(any_numpy_dtype_reduced)

# create array of object dtype from a scalar value (i.e. passing
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ def test_categories(self):
tm.assert_index_equal(result.categories, pd.Index(["a", "b", "c"]))
assert result.ordered is False

def test_equal_but_different(self, ordered):
def test_equal_but_different(self):
c1 = CategoricalDtype([1, 2, 3])
c2 = CategoricalDtype([1.0, 2.0, 3.0])
assert c1 is not c2
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/base/setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def test_setitem_series(self, data, full_indexer):
)
self.assert_series_equal(result, expected)

def test_setitem_frame_2d_values(self, data, request):
def test_setitem_frame_2d_values(self, data):
# GH#44514
df = pd.DataFrame({"A": data})
orig = df.copy()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def data(request):


@pytest.fixture
def data_for_twos(request):
def data_for_twos():
return SparseArray(np.ones(100) * 2)


Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_setitem_frame_length_0_str_key(self, indexer):
expected["A"] = expected["A"].astype("object")
tm.assert_frame_equal(df, expected)

def test_setitem_frame_duplicate_columns(self, using_array_manager, request):
def test_setitem_frame_duplicate_columns(self, using_array_manager):
# GH#15695
cols = ["A", "B", "C"] * 2
df = DataFrame(index=range(3), columns=cols)
Expand Down Expand Up @@ -1099,7 +1099,7 @@ def test_setitem_duplicate_columns_not_inplace(self):
@pytest.mark.parametrize(
"value", [1, np.array([[1], [1]], dtype="int64"), [[1], [1]]]
)
def test_setitem_same_dtype_not_inplace(self, value, using_array_manager, request):
def test_setitem_same_dtype_not_inplace(self, value, using_array_manager):
# GH#39510
cols = ["A", "B"]
df = DataFrame(0, index=[0, 1], columns=cols)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_interp_ignore_all_good(self):
result = df[["B", "D"]].interpolate(downcast=None)
tm.assert_frame_equal(result, df[["B", "D"]])

def test_interp_time_inplace_axis(self, axis):
def test_interp_time_inplace_axis(self):
# GH 9687
periods = 5
idx = date_range(start="2014-01-01", periods=periods)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def test_quantile_ea_with_na(self, obj, index):

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

# TODO(ArrayManager): this casting should be unnecessary after GH#39763 is fixed
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/methods/test_tz_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ def test_tz_convert_and_localize(self, fn):
# Not DatetimeIndex / PeriodIndex
with pytest.raises(TypeError, match="DatetimeIndex"):
df = DataFrame(index=int_idx)
df = getattr(df, fn)("US/Pacific")
getattr(df, fn)("US/Pacific")

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

# Invalid level
with pytest.raises(ValueError, match="not valid"):
df = DataFrame(index=l0)
df = getattr(df, fn)("US/Pacific", level=1)
getattr(df, fn)("US/Pacific", level=1)

@pytest.mark.parametrize("copy", [True, False])
def test_tz_convert_copy_inplace_mutate(self, copy, frame_or_series):
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/test_query_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def skip_if_no_pandas_parser(parser):


class TestCompat:
def setup_method(self, method):
def setup_method(self):
self.df = DataFrame({"A": [1, 2, 3]})
self.expected1 = self.df[self.df.A > 0]
self.expected2 = self.df.A + 1
Expand Down Expand Up @@ -1090,10 +1090,10 @@ def test_query_string_scalar_variable(self, parser, engine):


class TestDataFrameEvalWithFrame:
def setup_method(self, method):
def setup_method(self):
self.frame = DataFrame(np.random.randn(10, 3), columns=list("abc"))

def teardown_method(self, method):
def teardown_method(self):
del self.frame

def test_simple_expr(self, parser, engine):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_repr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_assign_index_sequences(self):
df.index = index
repr(df)

def test_repr_with_mi_nat(self, float_string_frame):
def test_repr_with_mi_nat(self):
df = DataFrame({"X": [1, 2]}, index=[[NaT, Timestamp("20130101")], ["a", "b"]])
result = repr(df)
expected = " X\nNaT a 1\n2013-01-01 b 2"
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_binary_input_dispatch_binop(dtype):
),
],
)
def test_ufunc_passes_args(func, arg, expected, request):
def test_ufunc_passes_args(func, arg, expected):
# GH#40662
arr = np.array([[1, 2], [3, 4]])
df = pd.DataFrame(arr)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_apply_with_mixed_dtype():
tm.assert_series_equal(result1, result2)


def test_groupby_as_index_apply(df):
def test_groupby_as_index_apply():
# GH #4648 and #3417
df = DataFrame(
{
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ def test_dataframe_groupby_on_2_categoricals_when_observed_is_true(reduction_fun

@pytest.mark.parametrize("observed", [False, None])
def test_dataframe_groupby_on_2_categoricals_when_observed_is_false(
reduction_func, observed, request
reduction_func, observed
):
# GH 23865
# GH 27075
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def test_groupby_as_index_corner(df, ts):
df.groupby(lambda x: x.lower(), as_index=False, axis=1)


def test_groupby_multiple_key(df):
def test_groupby_multiple_key():
df = tm.makeTimeDataFrame()
grouped = df.groupby([lambda x: x.year, lambda x: x.month, lambda x: x.day])
agged = grouped.sum()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_size(df, by):

@pytest.mark.parametrize("by", ["A", "B", ["A", "B"]])
@pytest.mark.parametrize("sort", [True, False])
def test_size_sort(df, sort, by):
def test_size_sort(sort, by):
df = DataFrame(np.random.choice(20, (1000, 3)), columns=list("ABC"))
left = df.groupby(by=by, sort=sort).size()
right = df.groupby(by=by, sort=sort)["C"].apply(lambda a: a.shape[0])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/categorical/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def simple_index(self) -> CategoricalIndex:
return self._index_cls(list("aabbca"), categories=list("cab"), ordered=False)

@pytest.fixture
def index(self, request):
def index(self):
return tm.makeCategoricalIndex(100)

def create_index(self, *, categories=None, ordered=False):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/datetimes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_intersection_non_tick_no_fastpath(self):


class TestBusinessDatetimeIndex:
def setup_method(self, method):
def setup_method(self):
self.rng = bdate_range(START, END)

def test_union(self, sort):
Expand Down Expand Up @@ -555,7 +555,7 @@ def test_intersection_duplicates(self, sort):


class TestCustomDatetimeIndex:
def setup_method(self, method):
def setup_method(self):
self.rng = bdate_range(START, END, freq="C")

def test_union(self, sort):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_union_sort_other_empty(slice_):


@pytest.mark.xfail(reason="Not implemented.")
def test_union_sort_other_empty_sort(slice_):
def test_union_sort_other_empty_sort():
# TODO(GH#25151): decide on True behaviour
# # sort=True
idx = MultiIndex.from_product([[1, 0], ["a", "b"]])
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def test_empty_fancy_raises(self, index):
with pytest.raises(IndexError, match=msg):
index[empty_farr]

def test_union_dt_as_obj(self, sort, simple_index):
def test_union_dt_as_obj(self, simple_index):
# TODO: Replace with fixturesult
index = simple_index
date_index = date_range("2019-01-01", periods=10)
Expand Down Expand Up @@ -792,7 +792,7 @@ def test_isin(self, values, index, expected):
result = index.isin(values)
tm.assert_numpy_array_equal(result, expected)

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

Expand Down Expand Up @@ -820,7 +820,7 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
np.array([False, False]),
)

def test_isin_nan_common_float64(self, request, nulls_fixture):
def test_isin_nan_common_float64(self, nulls_fixture):

if nulls_fixture is pd.NaT or nulls_fixture is pd.NA:
# Check 1) that we cannot construct a Float64Index with this value
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_numpy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_numpy_ufuncs_basic(index, func):
@pytest.mark.parametrize(
"func", [np.isfinite, np.isinf, np.isnan, np.signbit], ids=lambda x: x.__name__
)
def test_numpy_ufuncs_other(index, func, request):
def test_numpy_ufuncs_other(index, func):
# test ufuncs of numpy, see:
# https://numpy.org/doc/stable/reference/ufuncs.html
if isinstance(index, (DatetimeIndex, TimedeltaIndex)):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def test_difference_preserves_type_empty(self, index, sort):
expected = index[:0]
tm.assert_index_equal(result, expected, exact=True)

def test_difference_name_retention_equals(self, index, sort, names):
def test_difference_name_retention_equals(self, index, names):
if isinstance(index, MultiIndex):
names = [[x] * index.nlevels for x in names]
index = index.rename(names[0])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Base:
"multi",
}

def setup_method(self, method):
def setup_method(self):

self.series_ints = Series(np.random.rand(4), index=np.arange(0, 8, 2))
self.frame_ints = DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/multiindex/test_sorted.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_frame_getitem_not_sorted2(self, key):
assert result.index.is_monotonic_increasing
tm.assert_frame_equal(result, expected)

def test_sort_values_key(self, multiindex_dataframe_random_data):
def test_sort_values_key(self):
arrays = [
["bar", "bar", "baz", "baz", "qux", "qux", "foo", "foo"],
["one", "two", "one", "two", "one", "two", "one", "two"],
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class TestCategoricalIndex:
def setup_method(self, method):
def setup_method(self):

self.df = DataFrame(
{
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_insert_index_float64(self, insert, coerced_val, coerced_dtype):
"insert_value",
[pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
)
def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):
def test_insert_index_datetimes(self, fill_val, exp_dtype, insert_value):

obj = pd.DatetimeIndex(
["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz
Expand Down
Loading