Q. How to execute an individual test case when usi...
# general
r
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
-k option I believe, it's in the docs for the goal on tests
Follows the same standard that pytest uses
r
-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
Copy code
# Run just one test.
❯ ./pants test helloworld/util/lang_test.py -- -k test_language_translator
r
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
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?