Skip to content

IS_RUNNING_TESTS config should also detect Pytest runner #2136

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
paduszyk opened this issue May 14, 2025 · 1 comment · May be fixed by #2137
Open

IS_RUNNING_TESTS config should also detect Pytest runner #2136

paduszyk opened this issue May 14, 2025 · 1 comment · May be fixed by #2137

Comments

@paduszyk
Copy link

One may presume that pytest so popular that it is used with Django projects as often as the built-in manage.py test framework (usually including plugins, e.g. pytest-django). However, the IS_RUNNING_TESTS setting detects only the latter by default by looking for "test" in sys.argv.

Updating:

"IS_RUNNING_TESTS": "test" in sys.argv,

by:

    "IS_RUNNING_TESTS": ("test" in sys.argv) or "PYTEST_VERSION" in os.environ,

NOTE: Using PYTEST_VERSION variable is a recommended way for determining whether pytest is running; see pytest-dev/pytest#9502 (comment).

@tim-schilling
Copy link
Member

Thank you @paduszyk, I agree this is something we should do. For some reason, I thought we were already covering the pytest case, but I was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants