Description
The documentation for TestLoader.testNamePatterns in the module unittest says:
List of Unix shell-style wildcard test name patterns that test methods have to match to be included in test suites (see -v option).
...
Note that matches are always performed using fnmatch.fnmatchcase(), so unlike patterns passed to the -v option, simple substring patterns will have to be converted using * wildcards.
But the option -v only increases verbosity, does not accept an argument, and so doesn't work with test name patterns.
In my opinion, it should be an option -k, because the option -k is used to pass a pattern as the output of unittest --help
says:
-k TESTNAMEPATTERNS Only run tests which match the given substring
Also checking the source code, -k is bound to testNamePatterns
parser.add_argument('-k', dest='testNamePatterns',
action='append', type=_convert_select_pattern,
help='Only run tests which match the given substring')
I've created the PR in case the issue is correct.
Linked PRs
- gh-100824: Fix type for the documentation of unittest.TestLoader.testNamePatterns #100825
- [3.11] gh-100824: Fix typo in the documentation of unittest.TestLoader.testNamePatterns (GH-100825) #100838
- [3.10] gh-100824: Fix typo in the documentation of unittest.TestLoader.testNamePatterns (GH-100825) #100839