summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-09-16 16:05:59 (GMT)
committerGeorg Brandl <georg@python.org>2009-09-16 16:05:59 (GMT)
commitb044b2a701179dc6f8d50d28c7d4486e0d0d7a09 (patch)
tree3337a0b5e15ca883b815062cdac083449a093049 /Doc/library/unittest.rst
parentf4b4623a309fe2548e7b2987674b4e68f5b8f0e1 (diff)
downloadcpython-b044b2a701179dc6f8d50d28c7d4486e0d0d7a09.zip
cpython-b044b2a701179dc6f8d50d28c7d4486e0d0d7a09.tar.gz
cpython-b044b2a701179dc6f8d50d28c7d4486e0d0d7a09.tar.bz2
Merged revisions 74821,74828-74831,74833,74835 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ................ r74821 | georg.brandl | 2009-09-16 11:42:19 +0200 (Mi, 16 Sep 2009) | 1 line #6885: run python 3 as python3. ................ r74828 | georg.brandl | 2009-09-16 16:23:20 +0200 (Mi, 16 Sep 2009) | 1 line Use true booleans. ................ r74829 | georg.brandl | 2009-09-16 16:24:29 +0200 (Mi, 16 Sep 2009) | 1 line Small PEP8 correction. ................ r74830 | georg.brandl | 2009-09-16 16:36:22 +0200 (Mi, 16 Sep 2009) | 1 line Use true booleans. ................ r74831 | georg.brandl | 2009-09-16 17:54:04 +0200 (Mi, 16 Sep 2009) | 1 line Use true booleans and PEP8 for argdefaults. ................ r74833 | georg.brandl | 2009-09-16 17:58:14 +0200 (Mi, 16 Sep 2009) | 1 line Last round of adapting style of documenting argument default values. ................ r74835 | georg.brandl | 2009-09-16 18:00:31 +0200 (Mi, 16 Sep 2009) | 33 lines Merged revisions 74817-74820,74822-74824 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line Make deprecation notices as visible as warnings are right now. ........ r74818 | georg.brandl | 2009-09-16 11:23:04 +0200 (Mi, 16 Sep 2009) | 1 line #6880: add reference to classes section in exceptions section, which comes earlier. ........ r74819 | georg.brandl | 2009-09-16 11:24:57 +0200 (Mi, 16 Sep 2009) | 1 line #6876: fix base class constructor invocation in example. ........ r74820 | georg.brandl | 2009-09-16 11:30:48 +0200 (Mi, 16 Sep 2009) | 1 line #6891: comment out dead link to Unicode article. ........ r74822 | georg.brandl | 2009-09-16 12:12:06 +0200 (Mi, 16 Sep 2009) | 1 line #5621: refactor description of how class/instance attributes interact on a.x=a.x+1 or augassign. ........ r74823 | georg.brandl | 2009-09-16 15:06:22 +0200 (Mi, 16 Sep 2009) | 1 line Remove strange trailing commas. ........ r74824 | georg.brandl | 2009-09-16 15:11:06 +0200 (Mi, 16 Sep 2009) | 1 line #6892: fix optparse example involving help option. ........ ................
Diffstat (limited to 'Doc/library/unittest.rst')
-rw-r--r--Doc/library/unittest.rst66
1 files changed, 34 insertions, 32 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 9a57a0b..a637e07 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -525,7 +525,7 @@ This section describes in depth the API of :mod:`unittest`.
Test cases
~~~~~~~~~~
-.. class:: TestCase([methodName])
+.. class:: TestCase(methodName='runTest')
Instances of the :class:`TestCase` class represent the smallest testable units
in the :mod:`unittest` universe. This class is intended to be used as a base
@@ -576,7 +576,7 @@ Test cases
the outcome of the test method. The default implementation does nothing.
- .. method:: run([result])
+ .. method:: run(result=None)
Run the test, collecting the result into the test result object passed as
*result*. If *result* is omitted or :const:`None`, a temporary result
@@ -603,9 +603,9 @@ Test cases
failures.
- .. method:: assertTrue(expr[, msg])
- assert_(expr[, msg])
- failUnless(expr[, msg])
+ .. method:: assertTrue(expr, msg=None)
+ assert_(expr, msg=None)
+ failUnless(expr, msg=None)
Signal a test failure if *expr* is false; the explanation for the failure
will be *msg* if given, otherwise it will be :const:`None`.
@@ -614,8 +614,8 @@ Test cases
:meth:`failUnless`.
- .. method:: assertEqual(first, second[, msg])
- failUnlessEqual(first, second[, msg])
+ .. method:: assertEqual(first, second, msg=None)
+ failUnlessEqual(first, second, msg=None)
Test that *first* and *second* are equal. If the values do not compare
equal, the test will fail with the explanation given by *msg*, or
@@ -636,8 +636,8 @@ Test cases
:meth:`failUnlessEqual`.
- .. method:: assertNotEqual(first, second[, msg])
- failIfEqual(first, second[, msg])
+ .. method:: assertNotEqual(first, second, msg=None)
+ failIfEqual(first, second, msg=None)
Test that *first* and *second* are not equal. If the values do compare
equal, the test will fail with the explanation given by *msg*, or
@@ -650,8 +650,8 @@ Test cases
:meth:`failIfEqual`.
- .. method:: assertAlmostEqual(first, second[, places[, msg]])
- failUnlessAlmostEqual(first, second[, places[, msg]])
+ .. method:: assertAlmostEqual(first, second, *, places=7, msg=None)
+ failUnlessAlmostEqual(first, second, *, places=7, msg=None)
Test that *first* and *second* are approximately equal by computing the
difference, rounding to the given number of decimal *places* (default 7),
@@ -666,8 +666,8 @@ Test cases
:meth:`failUnlessAlmostEqual`.
- .. method:: assertNotAlmostEqual(first, second[, places[, msg]])
- failIfAlmostEqual(first, second[, places[, msg]])
+ .. method:: assertNotAlmostEqual(first, second, *, places=7, msg=None)
+ failIfAlmostEqual(first, second, *, places=7, msg=None)
Test that *first* and *second* are not approximately equal by computing
the difference, rounding to the given number of decimal *places* (default
@@ -708,7 +708,7 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertRegexpMatches(text, regexp[, msg=None]):
+ .. method:: assertRegexpMatches(text, regexp, msg=None):
Verifies that a *regexp* search matches *text*. Fails with an error
message including the pattern and the *text*. *regexp* may be
@@ -801,8 +801,10 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertRaises(exception[, callable, ...])
- failUnlessRaises(exception[, callable, ...])
+ .. method:: assertRaises(exception, callable, *args, **kwds)
+ failUnlessRaises(exception, callable, *args, **kwds)
+ assertRaises(exception)
+ failUnlessRaises(exception)
Test that an exception is raised when *callable* is called with any
positional or keyword arguments that are also passed to
@@ -811,8 +813,8 @@ Test cases
To catch any of a group of exceptions, a tuple containing the exception
classes may be passed as *exception*.
- If *callable* is omitted or None, returns a context manager so that the
- code under test can be written inline rather than as a function::
+ If only the *exception* argument is given, returns a context manager so
+ that the code under test can be written inline rather than as a function::
with self.failUnlessRaises(some_error_class):
do_something()
@@ -842,14 +844,14 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertIsNone(expr[, msg])
+ .. method:: assertIsNone(expr, msg=None)
This signals a test failure if *expr* is not None.
.. versionadded:: 3.1
- .. method:: assertIsNotNone(expr[, msg])
+ .. method:: assertIsNotNone(expr, msg=None)
The inverse of the :meth:`assertIsNone` method.
This signals a test failure if *expr* is None.
@@ -857,7 +859,7 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertIs(expr1, expr2[, msg])
+ .. method:: assertIs(expr1, expr2, msg=None)
This signals a test failure if *expr1* and *expr2* don't evaluate to the same
object.
@@ -865,7 +867,7 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertIsNot(expr1, expr2[, msg])
+ .. method:: assertIsNot(expr1, expr2, msg=None)
The inverse of the :meth:`assertIs` method.
This signals a test failure if *expr1* and *expr2* evaluate to the same
@@ -874,8 +876,8 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertFalse(expr[, msg])
- failIf(expr[, msg])
+ .. method:: assertFalse(expr, msg=None)
+ failIf(expr, msg=None)
The inverse of the :meth:`assertTrue` method is the :meth:`assertFalse` method.
This signals a test failure if *expr* is true, with *msg* or :const:`None`
@@ -885,7 +887,7 @@ Test cases
:meth:`failIf`.
- .. method:: fail([msg])
+ .. method:: fail(msg=None)
Signals a test failure unconditionally, with *msg* or :const:`None` for
the error message.
@@ -976,7 +978,7 @@ Test cases
.. versionadded:: 3.1
- .. method:: addCleanup(function[, *args[, **kwargs]])
+ .. method:: addCleanup(function, *args, **kwargs)
Add a function to be called after :meth:`tearDown` to cleanup resources
used during the test. Functions will be called in reverse order to the
@@ -1006,7 +1008,7 @@ Test cases
.. versionadded:: 2.7
-.. class:: FunctionTestCase(testFunc[, setUp[, tearDown[, description]]])
+.. class:: FunctionTestCase(testFunc, setUp=None, tearDown=None, description=None)
This class implements the portion of the :class:`TestCase` interface which
allows the test runner to drive the test, but does not provide the methods which
@@ -1020,7 +1022,7 @@ Test cases
Grouping tests
~~~~~~~~~~~~~~
-.. class:: TestSuite([tests])
+.. class:: TestSuite(tests=())
This class represents an aggregation of individual tests cases and test suites.
The class presents the interface needed by the test runner to allow it to be run
@@ -1127,7 +1129,7 @@ Loading and running tests
be useful when the fixtures are different and defined in subclasses.
- .. method:: loadTestsFromName(name[, module])
+ .. method:: loadTestsFromName(name, module=None)
Return a suite of all tests cases given a string specifier.
@@ -1152,7 +1154,7 @@ Loading and running tests
The method optionally resolves *name* relative to the given *module*.
- .. method:: loadTestsFromNames(names[, module])
+ .. method:: loadTestsFromNames(names, module=None)
Similar to :meth:`loadTestsFromName`, but takes a sequence of names rather
than a single name. The return value is a test suite which supports all
@@ -1369,7 +1371,7 @@ Loading and running tests
instead of repeatedly creating new instances.
-.. class:: TextTestRunner([stream[, descriptions[, verbosity]]])
+.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1)
A basic test runner implementation which prints results on standard error. It
has a few configurable parameters, but is essentially very simple. Graphical
@@ -1382,7 +1384,7 @@ Loading and running tests
subclasses to provide a custom ``TestResult``.
-.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit]]]]]])
+.. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=TextTestRunner, testLoader=unittest.defaultTestLoader, exit=True)
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