is there any way to modify the pytest path?
# general
w
is there any way to modify the pytest path?
c
this is the way Pants resolves the address (passed on the cli args) into targets. Pants sees "tests/" as relative to the cwd. see https://www.pantsbuild.org/docs/targets#target-addresses I think you want it relative to the repository root, you can prepend "//" to the path. so
pants test //tests/
. You might also need to test all targets recursively, so something like
pants test //tests::
or even just
pants test ::
w
You seems misunderstand my situation.
c
oh, indeed. I'm not sure if Pants has a mechanism for that. Is the main goal to change the PYTHONPATH or to change the cwd or something else?
w
Yes, I need a mechanism to change the cwd to make the pytest work
c
Hm, I'm honestly not sure. I can't check right now, but source roots might help? https://www.pantsbuild.org/docs/source-roots
w
It don't help.
c
you could have a pytest fixture in a
conftest.py
file with auto-use that does the cwd when starting the test run.