[docs] [issue32971] unittest.TestCase.assertRaises

NODA, Kai report at bugs.python.org
Wed Feb 28 12:58:02 EST 2018

New submission from NODA, Kai <nodakai at gmail.com>:


> If only the exception and possibly the msg arguments are given, return a context manager so that the code under test can be written inline rather than as a function:
>     with self.assertRaises(SomeException):
> When used as a context manager, assertRaises() accepts the additional keyword argument msg.

Perhaps we don't need the second sentence on the `msg` argument which isn't adding anything new.

Ideally it should be more clear when the method operates in context manager mode.
("If only" and "possibly" don't play nicely together.)
Maybe along the lines of "If no callable was passed as an argument ..." ? I haven't looked in to the actual implementation yet...

assignee: docs at python
components: Documentation
messages: 313061
nosy: docs at python, nodakai
priority: normal
severity: normal
status: open
title: unittest.TestCase.assertRaises
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the docs mailing list