Skip to content

Commit f6a0e44

Browse files
mroeschkeyehoshuadimarsky
authored andcommitted
TST: Remove unused fixtures in tests (pandas-dev#45843)
1 parent c4f9576 commit f6a0e44

File tree

12 files changed

+51
-66
lines changed

12 files changed

+51
-66
lines changed

pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ def indexer_ial(request):
17761776

17771777

17781778
@pytest.fixture
1779-
def using_array_manager(request):
1779+
def using_array_manager():
17801780
"""
17811781
Fixture to check if the array manager is being used.
17821782
"""

pandas/tests/apply/test_str.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_transform_groupby_kernel_series(string_series, op):
256256

257257

258258
@pytest.mark.parametrize("op", frame_transform_kernels)
259-
def test_transform_groupby_kernel_frame(axis, float_frame, op, request):
259+
def test_transform_groupby_kernel_frame(axis, float_frame, op):
260260
# TODO(2.0) Remove after pad/backfill deprecation enforced
261261
op = maybe_normalize_deprecated_kernels(op)
262262
# GH 35964

pandas/tests/frame/indexing/test_where.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_where_upcasting(self):
9898

9999
tm.assert_series_equal(result, expected)
100100

101-
def test_where_alignment(self, where_frame, float_string_frame, mixed_int_frame):
101+
def test_where_alignment(self, where_frame, float_string_frame):
102102
# aligning
103103
def _check_align(df, cond, other, check_dtypes=True):
104104
rs = df.where(cond, other)

pandas/tests/frame/methods/test_shift.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def test_shift_dt64values_int_fill_deprecated(self):
611611
)
612612
# TODO(2.0): remove filtering
613613
@pytest.mark.filterwarnings("ignore:Index.ravel.*:FutureWarning")
614-
def test_shift_dt64values_axis1_invalid_fill(self, vals, as_cat, request):
614+
def test_shift_dt64values_axis1_invalid_fill(self, vals, as_cat):
615615
# GH#44564
616616
ser = Series(vals)
617617
if as_cat:

pandas/tests/indexes/period/test_constructors.py

-3
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ def test_shallow_copy_requires_disallow_period_index(self):
534534

535535

536536
class TestSeriesPeriod:
537-
def setup_method(self, method):
538-
self.series = Series(period_range("2000-01-01", periods=10, freq="D"))
539-
540537
def test_constructor_cant_cast_period(self):
541538
msg = "Cannot cast PeriodIndex to dtype float64"
542539
with pytest.raises(TypeError, match=msg):

pandas/tests/indexing/test_loc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ def test_loc_setitem_with_expansion_inf_upcast_empty(self):
19791979
tm.assert_index_equal(result, expected)
19801980

19811981
@pytest.mark.filterwarnings("ignore:indexing past lexsort depth")
1982-
def test_loc_setitem_with_expansion_nonunique_index(self, index, request):
1982+
def test_loc_setitem_with_expansion_nonunique_index(self, index):
19831983
# GH#40096
19841984
if not len(index):
19851985
return

pandas/tests/io/json/test_json_table_schema.py

+41-37
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,39 @@
2424
)
2525

2626

27-
class TestBuildSchema:
28-
def setup_method(self, method):
29-
self.df = DataFrame(
30-
{
31-
"A": [1, 2, 3, 4],
32-
"B": ["a", "b", "c", "c"],
33-
"C": pd.date_range("2016-01-01", freq="d", periods=4),
34-
"D": pd.timedelta_range("1H", periods=4, freq="T"),
35-
},
36-
index=pd.Index(range(4), name="idx"),
37-
)
27+
@pytest.fixture
28+
def df_schema():
29+
return DataFrame(
30+
{
31+
"A": [1, 2, 3, 4],
32+
"B": ["a", "b", "c", "c"],
33+
"C": pd.date_range("2016-01-01", freq="d", periods=4),
34+
"D": pd.timedelta_range("1H", periods=4, freq="T"),
35+
},
36+
index=pd.Index(range(4), name="idx"),
37+
)
38+
39+
40+
@pytest.fixture
41+
def df_table():
42+
return DataFrame(
43+
{
44+
"A": [1, 2, 3, 4],
45+
"B": ["a", "b", "c", "c"],
46+
"C": pd.date_range("2016-01-01", freq="d", periods=4),
47+
"D": pd.timedelta_range("1H", periods=4, freq="T"),
48+
"E": pd.Series(pd.Categorical(["a", "b", "c", "c"])),
49+
"F": pd.Series(pd.Categorical(["a", "b", "c", "c"], ordered=True)),
50+
"G": [1.0, 2.0, 3, 4.0],
51+
"H": pd.date_range("2016-01-01", freq="d", periods=4, tz="US/Central"),
52+
},
53+
index=pd.Index(range(4), name="idx"),
54+
)
3855

39-
def test_build_table_schema(self):
40-
result = build_table_schema(self.df, version=False)
56+
57+
class TestBuildSchema:
58+
def test_build_table_schema(self, df_schema):
59+
result = build_table_schema(df_schema, version=False)
4160
expected = {
4261
"fields": [
4362
{"name": "idx", "type": "integer"},
@@ -49,7 +68,7 @@ def test_build_table_schema(self):
4968
"primaryKey": ["idx"],
5069
}
5170
assert result == expected
52-
result = build_table_schema(self.df)
71+
result = build_table_schema(df_schema)
5372
assert "pandas_version" in result
5473

5574
def test_series(self):
@@ -77,8 +96,8 @@ def test_series_unnamed(self):
7796
}
7897
assert result == expected
7998

80-
def test_multiindex(self):
81-
df = self.df.copy()
99+
def test_multiindex(self, df_schema):
100+
df = df_schema
82101
idx = pd.MultiIndex.from_product([("a", "b"), (1, 2)])
83102
df.index = idx
84103

@@ -195,21 +214,6 @@ def test_as_json_table_type_categorical_dtypes(self):
195214

196215

197216
class TestTableOrient:
198-
def setup_method(self, method):
199-
self.df = DataFrame(
200-
{
201-
"A": [1, 2, 3, 4],
202-
"B": ["a", "b", "c", "c"],
203-
"C": pd.date_range("2016-01-01", freq="d", periods=4),
204-
"D": pd.timedelta_range("1H", periods=4, freq="T"),
205-
"E": pd.Series(pd.Categorical(["a", "b", "c", "c"])),
206-
"F": pd.Series(pd.Categorical(["a", "b", "c", "c"], ordered=True)),
207-
"G": [1.0, 2.0, 3, 4.0],
208-
"H": pd.date_range("2016-01-01", freq="d", periods=4, tz="US/Central"),
209-
},
210-
index=pd.Index(range(4), name="idx"),
211-
)
212-
213217
def test_build_series(self):
214218
s = pd.Series([1, 2], name="a")
215219
s.index.name = "id"
@@ -259,8 +263,8 @@ def test_read_json_from_to_json_results(self):
259263
@pytest.mark.filterwarnings(
260264
"ignore:an integer is required (got type float)*:DeprecationWarning"
261265
)
262-
def test_to_json(self):
263-
df = self.df.copy()
266+
def test_to_json(self, df_table):
267+
df = df_table
264268
df.index.name = "idx"
265269
result = df.to_json(orient="table", date_format="iso")
266270
result = json.loads(result, object_pairs_hook=OrderedDict)
@@ -438,17 +442,17 @@ def test_to_json_categorical_index(self):
438442
@pytest.mark.filterwarnings(
439443
"ignore:an integer is required (got type float)*:DeprecationWarning"
440444
)
441-
def test_date_format_raises(self):
445+
def test_date_format_raises(self, df_table):
442446
msg = (
443447
"Trying to write with `orient='table'` and `date_format='epoch'`. Table "
444448
"Schema requires dates to be formatted with `date_format='iso'`"
445449
)
446450
with pytest.raises(ValueError, match=msg):
447-
self.df.to_json(orient="table", date_format="epoch")
451+
df_table.to_json(orient="table", date_format="epoch")
448452

449453
# others work
450-
self.df.to_json(orient="table", date_format="iso")
451-
self.df.to_json(orient="table")
454+
df_table.to_json(orient="table", date_format="iso")
455+
df_table.to_json(orient="table")
452456

453457
def test_convert_pandas_type_to_json_field_int(self, index_or_series):
454458
kind = index_or_series

pandas/tests/io/parser/test_parse_dates.py

-2
Original file line numberDiff line numberDiff line change
@@ -1713,8 +1713,6 @@ def test_hypothesis_delimited_date(
17131713
"e.g. %m.%Y is a float or a date"
17141714
)
17151715
)
1716-
result, expected = None, None
1717-
except_in_dateutil, except_out_dateutil = None, None
17181716
date_string = test_datetime.strftime(date_format.replace(" ", delimiter))
17191717

17201718
with warnings.catch_warnings():

pandas/tests/io/pytables/test_round_trip.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
pytestmark = pytest.mark.single
3434

3535

36-
def test_conv_read_write(setup_path):
36+
def test_conv_read_write():
3737
with tm.ensure_clean() as path:
3838

3939
def roundtrip(key, obj, **kwargs):
@@ -491,20 +491,6 @@ def _check_roundtrip(obj, comparator, path, compression=False, **kwargs):
491491
comparator(retrieved, obj, **kwargs)
492492

493493

494-
def _check_double_roundtrip(self, obj, comparator, path, compression=False, **kwargs):
495-
options = {}
496-
if compression:
497-
options["complib"] = compression or _default_compressor
498-
499-
with ensure_clean_store(path, "w", **options) as store:
500-
store["obj"] = obj
501-
retrieved = store["obj"]
502-
comparator(retrieved, obj, **kwargs)
503-
store["obj"] = retrieved
504-
again = store["obj"]
505-
comparator(again, obj, **kwargs)
506-
507-
508494
def _check_roundtrip_table(obj, comparator, path, compression=False):
509495
options = {}
510496
if compression:

pandas/tests/io/pytables/test_select.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def test_frame_select_complex(setup_path):
659659
tm.assert_frame_equal(result, expected)
660660

661661

662-
def test_frame_select_complex2(setup_path):
662+
def test_frame_select_complex2():
663663

664664
with ensure_clean_path(["params.hdf", "hist.hdf"]) as paths:
665665

pandas/tests/io/test_fsspec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_excel_options(fsspectest, extension):
153153

154154

155155
@td.skip_if_no("fastparquet")
156-
def test_to_parquet_new_file(monkeypatch, cleared_fs):
156+
def test_to_parquet_new_file(cleared_fs):
157157
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
158158
df1.to_parquet(
159159
"memory://test/test.csv", index=True, engine="fastparquet", compression=None

pandas/tests/io/test_parquet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def test_cross_engine_pa_fp(df_cross_compat, pa, fp):
353353
tm.assert_frame_equal(result, df[["a", "d"]])
354354

355355

356-
def test_cross_engine_fp_pa(request, df_cross_compat, pa, fp):
356+
def test_cross_engine_fp_pa(df_cross_compat, pa, fp):
357357
# cross-compat with differing reading/writing engines
358358
df = df_cross_compat
359359
with tm.ensure_clean() as path:
@@ -1135,7 +1135,7 @@ def test_timezone_aware_index(self, fp, timezone_aware_date_list):
11351135
expected.index.name = "index"
11361136
check_round_trip(df, fp, expected=expected)
11371137

1138-
def test_use_nullable_dtypes_not_supported(self, monkeypatch, fp):
1138+
def test_use_nullable_dtypes_not_supported(self, fp):
11391139
df = pd.DataFrame({"a": [1, 2]})
11401140

11411141
with tm.ensure_clean() as path:

0 commit comments

Comments
 (0)