Is there an existing such new check request for this?
Explain
It would be worthwhile to check that people are declaring EPYTEST_* variables prior to calling distutils_enable_tests. Since the variables are used both by that function and by epytest directly, declaring them past distutils_enable_tests will still give the "more obvious" result (such as using pytest-xdist) but without actually adding the dependencies.
That said, there are a few things to note:
- It is valid to declare/override
EPYTEST_* in phase functions, in particular if the dependencies are conditional. I think it would be good enough to catch uses without local.
- We recommend using the
: "${EPYTEST_TIMEOUT:=...}" form to let the user override the timeout. It would be nice to detect that form as well.
- Strictly speaking, not all
EPYTEST_* variables actually need to be set early. However, I think it's fine to catch all of them.
Examples
No response
Output message
EPYTEST_... variables declared after calling distutils_enable_tests
Documentation
The EPYTEST_* variables need to be declared prior to calling distutils_enable_tests, as that function uses them to add dependencies on appropriate pytest plugins. If adding the dependencies is undesirable, it is recommended to declare the variables local within the python_test() function, to make it clear.
Result level
warning
Is there an existing such new check request for this?
Explain
It would be worthwhile to check that people are declaring
EPYTEST_*variables prior to callingdistutils_enable_tests. Since the variables are used both by that function and byepytestdirectly, declaring them pastdistutils_enable_testswill still give the "more obvious" result (such as usingpytest-xdist) but without actually adding the dependencies.That said, there are a few things to note:
EPYTEST_*in phase functions, in particular if the dependencies are conditional. I think it would be good enough to catch uses withoutlocal.: "${EPYTEST_TIMEOUT:=...}"form to let the user override the timeout. It would be nice to detect that form as well.EPYTEST_*variables actually need to be set early. However, I think it's fine to catch all of them.Examples
No response
Output message
EPYTEST_...variables declared after callingdistutils_enable_testsDocumentation
The
EPYTEST_*variables need to be declared prior to callingdistutils_enable_tests, as that function uses them to add dependencies on appropriate pytest plugins. If adding the dependencies is undesirable, it is recommended to declare the variableslocalwithin thepython_test()function, to make it clear.Result level
warning