Skip to content

Commit a7ec6bd

Browse files
committed
TEST
1 parent 32c010c commit a7ec6bd

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

pandas/conftest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import pytest
1010
from pytz import FixedOffset, utc
1111

12+
import pandas.util._test_decorators as td
13+
1214
import pandas as pd
1315
from pandas import DataFrame
1416
import pandas.util.testing as tm
@@ -376,20 +378,23 @@ def unique_nulls_fixture(request):
376378
FixedOffset(0), FixedOffset(-300), timezone.utc,
377379
timezone(timedelta(hours=1)),
378380
timezone(timedelta(hours=-1), name='foo')]
381+
TIMEZONE_IDS = [repr(i) for i in TIMEZONES]
379382

380383

381-
@pytest.fixture(params=TIMEZONES, ids=repr)
384+
@td.parametrize_fixture_doc(str(TIMEZONE_IDS))
385+
@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS)
382386
def tz_naive_fixture(request):
383387
"""
384-
Fixture for trying timezones including default (None)
388+
Fixture for trying timezones including default (None): {0}
385389
"""
386390
return request.param
387391

388392

389-
@pytest.fixture(params=TIMEZONES[1:], ids=repr)
393+
@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:]))
394+
@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:])
390395
def tz_aware_fixture(request):
391396
"""
392-
Fixture for trying explicit timezones
397+
Fixture for trying explicit timezones: {0}
393398
"""
394399
return request.param
395400

pandas/util/_test_decorators.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,28 @@ def decorated_func(func):
157157
"installed->{installed}".format(
158158
enabled=_USE_NUMEXPR,
159159
installed=_NUMEXPR_INSTALLED))
160+
161+
162+
def parametrize_fixture_doc(*args):
163+
"""
164+
Intended for use as a decorator for parametrized fixture,
165+
this function will wrap the decorated function with a pytest
166+
``parametrize_fixture_doc`` mark. That mark will format
167+
initial fixture docstring by replacing placeholders {0}, {1} etc
168+
with parameters passed as arguments.
169+
170+
Parameters:
171+
----------
172+
args: iterable
173+
Positional arguments for docstring.
174+
175+
Returns:
176+
-------
177+
documented_fixture: function
178+
The decorated function wrapped within a pytest
179+
``parametrize_fixture_doc`` mark
180+
"""
181+
def documented_fixture(fixture):
182+
fixture.__doc__ = fixture.__doc__.format(*args)
183+
return fixture
184+
return documented_fixture

0 commit comments

Comments
 (0)