Skip to content

REF/TST: Add more pytest idiom to resample/test_datetime_index.py #24414

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 24 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c99d355
replace setup_method with fixtures
simonjayhawkins Dec 21, 2018
70021bb
use index fixture for test_custom_grouper
simonjayhawkins Dec 21, 2018
4062c25
use series fixture for test_resample_basic
simonjayhawkins Dec 21, 2018
b57ffae
use series fixture for test_resample_string_kwargs
simonjayhawkins Dec 21, 2018
a2049f6
parametrize test_resample_string_kwargs
simonjayhawkins Dec 21, 2018
1826669
use series fixture for test_resample_how
simonjayhawkins Dec 21, 2018
285aab2
use series fixture for test_resample_how_ohlc
simonjayhawkins Dec 21, 2018
731e399
parametrize test_resample_basic
simonjayhawkins Dec 21, 2018
2e3d4eb
parametrize test_numpy_compat
simonjayhawkins Dec 21, 2018
b957006
move timedelta tests to test_timedelta.py
simonjayhawkins Dec 21, 2018
525ec03
Merge remote-tracking branch 'upstream/master' into resample-dti
simonjayhawkins Dec 24, 2018
42da1c1
isort imports
simonjayhawkins Dec 24, 2018
df56265
add doc-strings to fixtures
simonjayhawkins Dec 24, 2018
238911e
suppress FutureWarning for Panel
simonjayhawkins Dec 24, 2018
55e8100
fix line too long warning
simonjayhawkins Dec 24, 2018
1b1aa87
remove class from test_datetime_index.py
simonjayhawkins Dec 25, 2018
3cb5982
remove class from test_timedelta.py
simonjayhawkins Dec 25, 2018
137f6e8
hoist imports in test_datetime_index.py
simonjayhawkins Dec 26, 2018
37d72a7
hoist import in test_timedelta.py
simonjayhawkins Dec 26, 2018
34ed69e
revert suppress Panel FutureWarning
simonjayhawkins Dec 26, 2018
4baba7c
Merge remote-tracking branch 'upstream/master' into resample-dti
simonjayhawkins Dec 26, 2018
4947d07
use pytest.raises as a context manager
simonjayhawkins Dec 26, 2018
d070899
Merge remote-tracking branch 'upstream/master' into resample-dti
simonjayhawkins Dec 27, 2018
55b3954
move test to test_timedelta.py
simonjayhawkins Dec 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions pandas/tests/resample/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,53 +57,85 @@ def _simple_period_range_series(start, end, freq='D'):

@pytest.fixture
def _index_start():
"""Fixture for parametrization of index, series and frame."""
return datetime(2005, 1, 1)


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


@pytest.fixture
def _index_freq():
"""Fixture for parametrization of index, series and frame."""
return 'D'


@pytest.fixture
def index(_index_factory, _index_start, _index_end, _index_freq):
return _index_factory(_index_start, _index_end, freq=_index_freq)
def _index_name():
"""Fixture for parametrization of index, series and frame."""
return None


@pytest.fixture
def index(_index_factory, _index_start, _index_end, _index_freq, _index_name):
"""Fixture for parametrization of date_range, period_range and
timedelta_range indexes"""
return _index_factory(
_index_start, _index_end, freq=_index_freq, name=_index_name)


@pytest.fixture
def _static_values(index):
"""Fixture for parametrization of values used in parametrization of
Series and DataFrames with date_range, period_range and
timedelta_range indexes"""
return np.arange(len(index))


@pytest.fixture
def _series_name():
"""Fixture for parametrization of Series name for Series used with
date_range, period_range and timedelta_range indexes"""
return None


@pytest.fixture
def series(index, _series_name, _static_values):
"""Fixture for parametrization of Series with date_range, period_range and
timedelta_range indexes"""
return Series(_static_values, index=index, name=_series_name)


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


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


@pytest.fixture
def empty_frame(series):
"""Fixture for parametrization of empty DataFrame with date_range,
period_range and timedelta_range indexes"""
index = series.index[:0]
return DataFrame(index=index)


@pytest.fixture(params=[Series, DataFrame])
def series_and_frame(request, series, frame):
"""Fixture for parametrization of Series and DataFrame with date_range,
period_range and timedelta_range indexes"""
if request.param == Series:
return series
if request.param == DataFrame:
Expand Down
Loading