Skip to content

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

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

Open
mroeschke opened this issue Jan 4, 2024 · 2 comments
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite

Comments

@mroeschke
Copy link
Member

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.

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite ExtensionArray Extending pandas with custom dtypes or arrays. labels Jan 4, 2024
@jorisvandenbossche
Copy link
Member

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
Copy link
Member

WillAyd commented Feb 26, 2024

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

  • all_boolean_reductions
  • all_numeric_reductions
  • comparison_op
  • all_arithmetic_operators
  • sort_by_key
  • groupby_apply_op
  • all_numeric_accumulations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

3 participants