How can I get rootdir or absolute paths of the discovered tests? #12686
-
Hi all, I am building a tool that runs external users tests to verify code changes. We want to discover the absolute paths of the tests that pytest discovers. Since if you add the rootdir path to the collected test path from I haven't found a good solution to find rootdir but to just use Is there a better way to directly get rootdir for a test setup before executing all the tests? Better yet, is there a reliable way to get the absolute paths of the tests that are discovered? Thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Your use case screens use a actual plugin instead of output parsing All data is readily available on the python side |
Beta Was this translation helpful? Give feedback.
To complement @RonnyPfannschmidt's answer, use a custom plugin and implement
pytest_collect_modifyitems
: each item will have its full path available then. It is also much more stable/safer than parsing the output, as the hook is part of the public/stable API.