https://pantsbuild.org/ logo
#general
Title
# general
p

plain-fireman-49959

06/27/2022, 8:28 AM
Hi everyone, quick question! is there a way to run the test target (
pytest
) by module? I don't want one process per file, as I'm using the
@fixture(scope="session")
and I'd like it to apply to the entire module. I think scoping on the module doesn't work either because of pants' parallelization.
w

wide-midnight-78598

06/27/2022, 12:21 PM
While I've never tried it, not that long ago another Pants user added this to the docs... Maybe a good place to start? Not quite per module, but perhaps this will lead somewhere useful. https://www.pantsbuild.org/docs/troubleshooting#controlling-test-parallelism
./pants --process-execution-local-parallelism=1 test ::
👀 1
h

hundreds-father-404

06/27/2022, 4:01 PM
h

happy-kitchen-89482

06/27/2022, 4:45 PM
Not to be a pedant, but just to clarify the question: a module in python is equivalent to a single file. Did you mean package?
p

plain-fireman-49959

07/06/2022, 11:22 AM
(sorry for the late reply, this is a company project and my priorities are shifting a lot lately) Indeed I mean package, let's say I have a folder
tests/api/
with a BUILD file, a
conftest.py
and a
pytest.ini
file. I'd like to run all the tests contained in its sub-folder (i.e.
tests/api/a_tests/*.py
and
tests/api/b_tests/*.py
) in one single pants instance. Is this possibility already present? using the
--process-execution-local-parallelism=1
flag can work for us, as we want to prevent concurrent access to a common resource, it would be great to support it as one single run as I can't find a way to avoid rebuilding the entire resource for each package.