pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.47k stars 17.87k forks source link

TST: Ensure base ExtensionArray tests do not use any fixtures in `conftest.py` #56735

Open mroeschke opened 9 months ago

mroeschke commented 9 months ago

geopandas currently needs to copy over some fixtures used in our base EA tests which is not ideal for portability.

https://github.com/geopandas/geopandas/blob/08c23312edd8b0df25621f0fc77417840efe1fb5/geopandas/tests/test_extension_array.py#L246-L247

Ideally we should have a check that these tests do no use any external fixtures defined in pandas/conftest.py or ensure pandas/tests/extension/conftest.py contains the needed fixtures and instruct authors to copy over this file as well.

jorisvandenbossche commented 8 months ago

As a way to have some test in our own code base that might remind us about this: we could run the tests for one of our own extension arrays outside of the main test directory.

For example, we have some tests in scripts/tests that are run, and those won't pick up the pandas/conftest.py, I think. It doesn't exactly fit in there (as it is not testing a utility, but being an actual test in itself), but putting it there makes that we can easily use the workflow that already run those tests anyway (or without having to add a specific extra step in the CI setup. Not that this would be that complicated, though)

Concretely, the tests in pandas/tests/extension/test_datetime.py seem fairly complete and not too complex (not much overrides or skips). We could duplicate the content of that file with some minor edits in a file like scripts/tests/test_extension_array_tests_fixtures.py. That would ensure whenever we use a new fixture in the extension tests, it reminds us about this setup, and ensure we use fixtures from pandas/tests/extension/conftest.py.

WillAyd commented 7 months ago

I've noticed at least the following fixtures are problematic in this regards: