Skip to content

Possible typo in the documentation of unittest.TestLoader.testNamePatterns #100824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
busywhitespace opened this issue Jan 7, 2023 · 1 comment
Labels
docs Documentation in the Doc dir

Comments

@busywhitespace
Copy link
Contributor

busywhitespace commented Jan 7, 2023

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

@busywhitespace busywhitespace added the docs Documentation in the Doc dir label Jan 7, 2023
@sobolevn sobolevn changed the title Possible type in the documentation of unittest.TestLoader.testNamePatterns Possible typo in the documentation of unittest.TestLoader.testNamePatterns Jan 7, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 8, 2023
….testNamePatterns (pythonGH-100825)

(cherry picked from commit 6d3bc4a)

Co-authored-by: busywhitespace <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 8, 2023
….testNamePatterns (pythonGH-100825)

(cherry picked from commit 6d3bc4a)

Co-authored-by: busywhitespace <[email protected]>
miss-islington added a commit that referenced this issue Jan 8, 2023
…amePatterns (GH-100825)

(cherry picked from commit 6d3bc4a)

Co-authored-by: busywhitespace <[email protected]>
miss-islington added a commit that referenced this issue Jan 8, 2023
…amePatterns (GH-100825)

(cherry picked from commit 6d3bc4a)

Co-authored-by: busywhitespace <[email protected]>
@hugovk
Copy link
Member

hugovk commented Jan 8, 2023

Closing, this has been fixed in main, 3.11 and 3.10. Thanks!

@hugovk hugovk closed this as completed Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants