You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unittest - use contexts to assert exceptions #48694
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2008-12-28.14:29:38.952>created_at=<Date2008-11-27.09:49:59.368>labels= ['type-feature', 'library']
title='unittest - use contexts to assert exceptions'updated_at=<Date2008-12-28.14:29:38.951>user='https://bugs.python.org/dleonard0'
I like this change, since assertRaises can be a bit messy when passing it
a local function.
I'd suggest modifying the patch such that the AssertRaisesContext class is
also used when callableObj is provided, which would eliminate the
duplication of the code that checks for exceptions.
Activity
dleonard0 commentedon Nov 27, 2008
Patch to allow unit tests to test for exceptions through a 'with'
statement. Resulting (failing) test would look like this:
This saves having to put exception raising tests into a try/except
block, which is cool. And by cool I mean totally sweet.
purcell commentedon Nov 27, 2008
I like this change, since assertRaises can be a bit messy when passing it
a local function.
I'd suggest modifying the patch such that the AssertRaisesContext class is
also used when callableObj is provided, which would eliminate the
duplication of the code that checks for exceptions.
pitrou commentedon Dec 28, 2008
I've committed an improved patch, with tests and doc, in r67979 and
r67981. Thanks!