https://pantsbuild.org/ logo
m

melodic-thailand-99227

12/22/2021, 6:37 AM
Is there a way to use pants to list all the tests (not test targets)?
h

hundreds-father-404

12/22/2021, 6:53 AM
What do you mean? All the test files? If so, there is indeed! From https://www.pantsbuild.org/docs/existing-repositories#3-set-up-tests
Copy code
./pants filter --target-type=python_test :: | \
  xargs ./pants peek | \
  jq -r '.[] | select(.skip_tests== true) | .["sources"][]'
(You'll want to remove that
skip_test
snippet)
m

melodic-thailand-99227

12/22/2021, 7:01 AM
I’m sorry if I wasn’t clear. Not test files, the individual tests. If I have a file named
test_foo.py
with 2 individual
test_a
and
test_b
I’d like to get
test_a
and
test_b
h

hundreds-father-404

12/22/2021, 7:06 AM
Ah, the best I could think is to use `./pants test :: -- --collect-only`: https://stackoverflow.com/questions/50728351/using-pytest-collect-only-to-only-return-individual-test-names
1
m

melodic-thailand-99227

12/22/2021, 7:09 AM
I hoped I could query the pants cache
h

happy-kitchen-89482

12/22/2021, 7:25 AM
Pants caches at the file level, it doesn't know about individual tests in the file
That is potential future work