Is there a way to use pants to list all the tests ...
# general
m
Is there a way to use pants to list all the tests (not test targets)?
h
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
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
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
I hoped I could query the pants cache
h
Pants caches at the file level, it doesn't know about individual tests in the file
That is potential future work