diff options
author | Jonas Haag <jonas@lophus.org> | 2017-11-25 15:23:52 (GMT) |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2017-11-25 15:23:52 (GMT) |
commit | 5b48dc638b7405fd9bde4d854bf477dfeaaddf44 (patch) | |
tree | 2e3b44b9193cc1a0e08a6e1d65dd324e76fb3ee6 /Doc | |
parent | 8d9bb11d8fcbf10cc9b1eb0a647bcf3658a4e3dd (diff) | |
download | cpython-5b48dc638b7405fd9bde4d854bf477dfeaaddf44.zip cpython-5b48dc638b7405fd9bde4d854bf477dfeaaddf44.tar.gz cpython-5b48dc638b7405fd9bde4d854bf477dfeaaddf44.tar.bz2 |
bpo-32071: Add unittest -k option (#4496)
* bpo-32071: Add unittest -k option
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.rst | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index e52f140..4755488 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -219,6 +219,22 @@ Command-line options Stop the test run on the first error or failure. +.. cmdoption:: -k + + Only run test methods and classes that match the pattern or substring. + This option may be used multiple times, in which case all test cases that + match of the given patterns are included. + + Patterns that contain a wildcard character (``*``) are matched against the + test name using :meth:`fnmatch.fnmatchcase`; otherwise simple case-sensitive + substring matching is used. + + Patterns are matched against the fully qualified test method name as + imported by the test loader. + + For example, ``-k foo`` matches ``foo_tests.SomeTest.test_something``, + ``bar_tests.SomeTest.test_foo``, but not ``bar_tests.FooTest.test_something``. + .. cmdoption:: --locals Show local variables in tracebacks. @@ -229,6 +245,9 @@ Command-line options .. versionadded:: 3.5 The command-line option ``--locals``. +.. versionadded:: 3.7 + The command-line option ``-k``. + The command line can also be used for test discovery, for running all of the tests in a project or just a subset. @@ -1745,6 +1764,21 @@ Loading and running tests This affects all the :meth:`loadTestsFrom\*` methods. + .. attribute:: testNamePatterns + + List of Unix shell-style wildcard test name patterns that test methods + have to match to be included in test suites (see ``-v`` option). + + If this attribute is not ``None`` (the default), all test methods to be + included in test suites must match one of the patterns in this list. + Note that matches are always performed using :meth:`fnmatch.fnmatchcase`, + so unlike patterns passed to the ``-v`` option, simple substring patterns + will have to be converted using ``*`` wildcards. + + This affects all the :meth:`loadTestsFrom\*` methods. + + .. versionadded:: 3.7 + .. class:: TestResult |