diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-04-30 16:05:57 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-04-30 16:05:57 (GMT) |
commit | 30abb3a6a8e2acf812f5fad28774e27ecefc1ac7 (patch) | |
tree | 6dc535f43fbb871e40251362a17b83dfd1273f26 /Doc | |
parent | 524bc3993fc4edd17fdc0dc7a518d2b0b371b9ca (diff) | |
download | cpython-30abb3a6a8e2acf812f5fad28774e27ecefc1ac7.zip cpython-30abb3a6a8e2acf812f5fad28774e27ecefc1ac7.tar.gz cpython-30abb3a6a8e2acf812f5fad28774e27ecefc1ac7.tar.bz2 |
#14558: document the module, argv, and testLoader args of unittest.main.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.rst | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 1782e23..32d319f 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -1784,11 +1784,12 @@ Loading and running tests stream, descriptions, verbosity -.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit[, verbosity[, failfast[, catchbreak[,buffer]]]]]]]]]]) +.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit[, verbosity[, failfast[, catchbreak[, buffer]]]]]]]]]]) - A command-line program that runs a set of tests; this is primarily for making - test modules conveniently executable. The simplest use for this function is to - include the following line at the end of a test script:: + A command-line program that loads a set of tests from *module* and runs them; + this is primarily for making test modules conveniently executable. + The simplest use for this function is to include the following line at the + end of a test script:: if __name__ == '__main__': unittest.main() @@ -1799,10 +1800,17 @@ Loading and running tests if __name__ == '__main__': unittest.main(verbosity=2) + The *argv* argument can be a list of options passed to the program, with the + first element being the program name. If not specified or ``None``, + the values of :data:`sys.argv` are used. + The *testRunner* argument can either be a test runner class or an already created instance of it. By default ``main`` calls :func:`sys.exit` with an exit code indicating success or failure of the tests run. + The *testLoader* argument has to be a :class:`TestLoader` instance, + and defaults to :data:`defaultTestLoader`. + ``main`` supports being used from the interactive interpreter by passing in the argument ``exit=False``. This displays the result on standard output without calling :func:`sys.exit`:: @@ -1810,14 +1818,14 @@ Loading and running tests >>> from unittest import main >>> main(module='test_module', exit=False) - The ``failfast``, ``catchbreak`` and ``buffer`` parameters have the same + The *failfast*, *catchbreak* and *buffer* parameters have the same effect as the same-name `command-line options`_. Calling ``main`` actually returns an instance of the ``TestProgram`` class. This stores the result of the tests run as the ``result`` attribute. .. versionchanged:: 2.7 - The ``exit``, ``verbosity``, ``failfast``, ``catchbreak`` and ``buffer`` + The *exit*, *verbosity*, *failfast*, *catchbreak* and *buffer* parameters were added. |