Skip to content

Commit ccaaf86

Browse files
simonjayhawkinsPingviinituutti
authored andcommitted
REF/TST: Add more pytest idiom to resample/test_datetime_index.py (pandas-dev#24414)
1 parent 031a269 commit ccaaf86

File tree

3 files changed

+1539
-1429
lines changed

3 files changed

+1539
-1429
lines changed

pandas/tests/resample/conftest.py

+34-2
Original file line numberDiff line numberDiff line change
@@ -57,53 +57,85 @@ def _simple_period_range_series(start, end, freq='D'):
5757

5858
@pytest.fixture
5959
def _index_start():
60+
"""Fixture for parametrization of index, series and frame."""
6061
return datetime(2005, 1, 1)
6162

6263

6364
@pytest.fixture
6465
def _index_end():
66+
"""Fixture for parametrization of index, series and frame."""
6567
return datetime(2005, 1, 10)
6668

6769

6870
@pytest.fixture
6971
def _index_freq():
72+
"""Fixture for parametrization of index, series and frame."""
7073
return 'D'
7174

7275

7376
@pytest.fixture
74-
def index(_index_factory, _index_start, _index_end, _index_freq):
75-
return _index_factory(_index_start, _index_end, freq=_index_freq)
77+
def _index_name():
78+
"""Fixture for parametrization of index, series and frame."""
79+
return None
80+
81+
82+
@pytest.fixture
83+
def index(_index_factory, _index_start, _index_end, _index_freq, _index_name):
84+
"""Fixture for parametrization of date_range, period_range and
85+
timedelta_range indexes"""
86+
return _index_factory(
87+
_index_start, _index_end, freq=_index_freq, name=_index_name)
7688

7789

7890
@pytest.fixture
7991
def _static_values(index):
92+
"""Fixture for parametrization of values used in parametrization of
93+
Series and DataFrames with date_range, period_range and
94+
timedelta_range indexes"""
8095
return np.arange(len(index))
8196

8297

98+
@pytest.fixture
99+
def _series_name():
100+
"""Fixture for parametrization of Series name for Series used with
101+
date_range, period_range and timedelta_range indexes"""
102+
return None
103+
104+
83105
@pytest.fixture
84106
def series(index, _series_name, _static_values):
107+
"""Fixture for parametrization of Series with date_range, period_range and
108+
timedelta_range indexes"""
85109
return Series(_static_values, index=index, name=_series_name)
86110

87111

88112
@pytest.fixture
89113
def empty_series(series):
114+
"""Fixture for parametrization of empty Series with date_range,
115+
period_range and timedelta_range indexes"""
90116
return series[:0]
91117

92118

93119
@pytest.fixture
94120
def frame(index, _series_name, _static_values):
121+
"""Fixture for parametrization of DataFrame with date_range, period_range
122+
and timedelta_range indexes"""
95123
# _series_name is intentionally unused
96124
return DataFrame({'value': _static_values}, index=index)
97125

98126

99127
@pytest.fixture
100128
def empty_frame(series):
129+
"""Fixture for parametrization of empty DataFrame with date_range,
130+
period_range and timedelta_range indexes"""
101131
index = series.index[:0]
102132
return DataFrame(index=index)
103133

104134

105135
@pytest.fixture(params=[Series, DataFrame])
106136
def series_and_frame(request, series, frame):
137+
"""Fixture for parametrization of Series and DataFrame with date_range,
138+
period_range and timedelta_range indexes"""
107139
if request.param == Series:
108140
return series
109141
if request.param == DataFrame:

0 commit comments

Comments
 (0)