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

rhythmic-morning-87313

05/15/2022, 4:45 AM
Q. How to execute an individual test case when using
python_tests()
with pytest? (i.e., select specific test(s) to run)
1
I could narrow down the scope by specifying auto-generated file-level targets like
./pants test tests/manager/test_scheduler.py:
and but could not so for individual cases.
g

green-match-66337

05/15/2022, 4:54 AM
-k option I believe, it's in the docs for the goal on tests
Follows the same standard that pytest uses
r

rhythmic-morning-87313

05/15/2022, 5:51 AM
-k
option is for selecting markers
i just want to select individual test case by their names
it seems that pants parallelizes pytests in the granularity of modules..
hmm
g

green-match-66337

05/15/2022, 9:07 AM
Copy code
# Run just one test.
❯ ./pants test helloworld/util/lang_test.py -- -k test_language_translator
r

rhythmic-morning-87313

05/15/2022, 9:16 AM
ok, it works, but i found that unnamed
python_tests()
does not make the test cases recognized by pants
i had to manually add
name
kwarg to
python_tests()
which is automatically added by
./pants tailor
in a subdirectory of test suite.
👍 1
h

happy-kitchen-89482

05/15/2022, 2:52 PM
Hmm, you shouldn't need to add a
name
, if there isn't one then the target name defaults to the name of the enclosing directory. But that means that only one target in a directory can omit the
name
. Was that the case?
3 Views