Skip to content

TST: use fixtures in Index common tests #16835

Closed
@jreback

Description

@jreback

https://github.com/pandas-dev/pandas/blob/master/pandas/tests/indexes/test_base.py#L36 we define a lot of self.indices that are used in testing (mostly in .common.py), where we iteratore over .indices.values()

if this were made into a parameterize fixture, then the tests can be changed to be a lot simpler. something like.

@pytest.fixture(params=[tm.makeUnicodeIndex(...), tm.make......])
def index(request):
    return request.param

# in common.py
def test_wrong_number_names(self, index):
    def testit(ind):
        ind.names = ["apple", "banana", "carrot"]
    tm.assert_raises_regex(ValueError, "^Length", testit, index)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Testingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions