Skip to content

Commit

Permalink
DOC: Fixture docs in pandas/conftest.py (#30917)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung authored and WillAyd committed Jan 11, 2020
1 parent 939e7dd commit b47a454
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,28 @@ def pytest_runtest_setup(item):
pytest.skip("skipping high memory test since --run-high-memory was not set")


# Configurations for all tests and all test modules


@pytest.fixture(autouse=True)
def configure_tests():
"""
Configure settings for all tests and test modules.
"""
pd.set_option("chained_assignment", "raise")


# For running doctests: make np and pd names available


@pytest.fixture(autouse=True)
def add_imports(doctest_namespace):
"""
Make `np` and `pd` names available for doctests.
"""
doctest_namespace["np"] = np
doctest_namespace["pd"] = pd


@pytest.fixture(params=["bsr", "coo", "csc", "csr", "dia", "dok", "lil"])
def spmatrix(request):
"""
Yields scipy sparse matrix classes.
"""
from scipy import sparse

return getattr(sparse, request.param + "_matrix")
Expand All @@ -92,8 +95,8 @@ def spmatrix(request):
@pytest.fixture(params=[0, 1, "index", "columns"], ids=lambda x: f"axis {repr(x)}")
def axis(request):
"""
Fixture for returning the axis numbers of a DataFrame.
"""
Fixture for returning the axis numbers of a DataFrame.
"""
return request.param


Expand Down Expand Up @@ -237,6 +240,10 @@ def all_boolean_reductions(request):

@pytest.fixture(params=list(_cython_table))
def cython_table_items(request):
"""
Yields a tuple of a function and its corresponding name. Correspond to
the list of aggregator "Cython functions" used on selected table items.
"""
return request.param


Expand Down Expand Up @@ -337,6 +344,9 @@ def writable(request):

@pytest.fixture(scope="module")
def datetime_tz_utc():
"""
Yields the UTC timezone object from the datetime module.
"""
return timezone.utc


Expand All @@ -358,6 +368,9 @@ def join_type(request):

@pytest.fixture
def strict_data_files(pytestconfig):
"""
Returns the configuration for the test setting `--strict-data-files`.
"""
return pytestconfig.getoption("--strict-data-files")


Expand Down

0 comments on commit b47a454

Please sign in to comment.