Skip to content
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

add_marker with usefixtures no longer works with pytest 8.0.0 #11873

Open
rhshadrach opened this issue Jan 28, 2024 · 4 comments
Open

add_marker with usefixtures no longer works with pytest 8.0.0 #11873

rhshadrach opened this issue Jan 28, 2024 · 4 comments
Labels
type: regression indicates a problem that was introduced in a release which was working previously

Comments

@rhshadrach
Copy link

I believe this may be related to #3664.

In pandas, we dynamically add a marker for our doctests so that we don't need import pandas as pd and import numpy as np in every docstring.

https://github.com/pandas-dev/pandas/blob/9008ee5810c09bc907b5fdc36fc3c1dff4a50c55/pandas/conftest.py#L191-L198

The add_doctest_imports fixture is here.

https://github.com/pandas-dev/pandas/blob/9008ee5810c09bc907b5fdc36fc3c1dff4a50c55/pandas/conftest.py#L253-L259

With pytest 8.0.0, add_marker no longer has any effect. Is the intentional, and if so, is there an alternative?

@bluetech
Copy link
Member

Very similar to #11759. Would the alternative described there of using an autouse fixture instead of the hook work for pandas?

@rhshadrach
Copy link
Author

Thanks! There is a comment in the pandas code that we don't use autouse because of perf. I'll see if I can track down the history there and see if I can reproduce the perf issue.

@rhshadrach
Copy link
Author

This was originally changed in pandas in pandas-dev/pandas#45667. It tried undoing that patch locally, seeing negligible differences in runtimes for the test suite. Will see what it looks like on the pandas CI in pandas-dev/pandas#57122.

@mroeschke
Copy link

It would be nice if an alternative to an autouse fixture could be used in the future as non-doctests don't need this fixture at all (which is probably +98% of tests in pandas).

The prior motivation for doing this dynamically was me being curious why in the durations output the last-ran unit test TEARDOWN could be one of the longest durations, and removing an autouse=True, doctest_namespace fixture was the culprit.

@Zac-HD Zac-HD added the type: regression indicates a problem that was introduced in a release which was working previously label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

4 participants