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

autouse fixtures named with a leading underscore do not run #12404

Closed
tamird opened this issue May 31, 2024 · 2 comments
Closed

autouse fixtures named with a leading underscore do not run #12404

tamird opened this issue May 31, 2024 · 2 comments

Comments

@tamird
Copy link
Contributor

tamird commented May 31, 2024

Very simple:

@pytest.fixture(autouse=True)
def foo(request: pytest.FixtureRequest) -> None:
  print("this runs")

@pytest.fixture(autouse=True)
def _foo(request: pytest.FixtureRequest) -> None:
  print("this does not run")

This causes ruff's PT004 to emit false positives. Let me know if this is intended behavior (though I didn't find documentation of that fact) and I'll send the bug over to ruff.

@bluetech
Copy link
Member

bluetech commented Jun 1, 2024

I tried it and it works for me. Maybe you're using some plugin which affects this? Do you have a standalone reproduction?

@tamird
Copy link
Contributor Author

tamird commented Jun 1, 2024

Ah yeah, this is PEBKAC. My fixtures are shared between packages and glob imported into each package's conftest.py -- and underscored fixtures aren't being imported.

@tamird tamird closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants