getting list of added tests ?
Closed this issue · 3 comments
Is there a way to recover the list of tests that were added by a call to pytest_discover_tests
?
The tests I'm dealing with do need some extra env variable(s) to be set, and from what I see in the implementation there's no way to inject more ENVIRONMENT
besides PYTHONPATH
and XXLD_LIBRARY_PATH
, am I correct ?
So getting a list of added tests would allow to call set_property(TEST ... APPEND PROPERTY ENVIRONMENT SOMEVAR=...)
afterwards.
Hi @aphecetche, apologize for the very late reply!
I'm actually working on adding an ENVIRONMENT
option for the pytest_discover_tests
, so that extra environment variables could be added as follows:
pytest_discover_tests(
PythonTest
...
ENVIRONMENT
"ENV1=TEST1"
"ENV2=TEST2"
)
I'll update this thread once I have a PR ready!
getting a list of added tests would allow to call set_property(TEST ... APPEND PROPERTY ENVIRONMENT SOMEVAR=...) afterwards.
The tests are created via a separated CMake scripts, discovered via the TEST_INCLUDE_FILES variable, so I'm not sure it would be possible to propagate a variable with all added tests. I'll do some testing and will get back to you.
So, it isn't possible to set a CMake variable from the executed script, so I don't see an easy way to retrieve the list of added test so that it can be processed afterwards.
However, I have a working prototype with the ENVIRONMENT
argument that I will release shortly: #15
Release as version 0.3.0
https://pytest-cmake.readthedocs.io/en/stable/release/release_notes.html#release-0.3.0
Please reopen the ticket is it doesn't work as expected!