Replies: 1 comment
|
Hi @Novakov The wrapper should not always append pytest already has the behavior you want through Put the default in pytest configuration, for example: [pytest]
testpaths = hw_testsand make the wrapper invoke pytest without adding cmdline = [
sys.executable,
"-m",
"pytest",
"--argument",
"abc",
*sys.argv[1:],
]Because your wrapper should work from arbitrary directories, also run pytest with the project/config directory as its working directory: subprocess.run(cmdline, cwd=project_root)Then: uses uses only that explicitly supplied test file, so it is not collected once through the directory and a second time through the file. This also gives pytest a consistent place from which to discover the root configuration/conftest containing Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Project I'm working on is using wrapper around pytest that automatically generates few required custom parameters and we recently found issue with explicit file paths. As I was not able to narrow down the problem to simple & small use case, repository https://github.com/Novakov/pytest-path-problem contains detailed description and reproduction of the issue.
It can be summarised with: how can I tell pytest to use directory X if no other directory/file is provided (so call
pytest --base-dir=Xis equal topytest Xandpytest --base-dir=X file1.pyis equal topytest file1.py).It is quite possible that it is not possible to do (and I'm okay with that) but I'm not giving up hope yet, any suggestion what I can try is welcome.
All reactions