diff options
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/unittest.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 792a98e..96eebf2 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -613,8 +613,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 @@ -622,6 +622,13 @@ 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*. + .. versionchanged:: 2.2 + + 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]) |