summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-12-28 14:29:00 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2008-12-28 14:29:00 (GMT)
commit5acd41e0a1663127ac0c01b00e934ee1e7f537a9 (patch)
treee0bd0969b40f38ce562bf1b2284110350ff176c7 /Doc
parentccc47b6eee267d6661c8521578e2fc9d53494029 (diff)
downloadcpython-5acd41e0a1663127ac0c01b00e934ee1e7f537a9.zip
cpython-5acd41e0a1663127ac0c01b00e934ee1e7f537a9.tar.gz
cpython-5acd41e0a1663127ac0c01b00e934ee1e7f537a9.tar.bz2
Merged revisions 67979 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67979 | antoine.pitrou | 2008-12-28 15:09:36 +0100 (dim., 28 déc. 2008) | 3 lines Issue #4444: Allow assertRaises() to be used as a context handler. ........
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/unittest.rst9
1 files changed, 7 insertions, 2 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 4ffafb0..95ba1c4 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -609,8 +609,8 @@ failures.
equal, the test will fail with the explanation given by *msg*, or :const:`None`.
-.. method:: TestCase.assertRaises(exception, callable, ...)
- TestCase.failUnlessRaises(exception, callable, ...)
+.. method:: TestCase.assertRaises(exception[, callable, ...])
+ TestCase.failUnlessRaises(exception[, callable, ...])
Test that an exception is raised when *callable* is called with any positional
or keyword arguments that are also passed to :meth:`assertRaises`. The test
@@ -618,6 +618,11 @@ failures.
fails if no exception is raised. 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::
+
+ with self.failUnlessRaises(some_error_class):
+ do_something()
.. method:: TestCase.failIf(expr[, msg])
TestCase.assertFalse(expr[, msg])