Issue4444
Created on 2008-11-27 09:49 by dleonard0, last changed 2008-12-28 14:29 by pitrou.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
unittest.patch
|
dleonard0,
2008-11-27 09:49
|
patych to unittest.py |
|
|
|
msg76492 - (view) |
Author: David Leonard (dleonard0) |
Date: 2008-11-27 09:49 |
|
Patch to allow unit tests to test for exceptions through a 'with'
statement. Resulting (failing) test would look like this:
import unittest
class T(unittest.TestCase):
def runTest(self):
with self.assertRaises(KeyError):
raise ValueError
This saves having to put exception raising tests into a try/except
block, which is cool. And by cool I mean totally sweet.
|
|
msg76500 - (view) |
Author: Steve Purcell (purcell) |
Date: 2008-11-27 14:07 |
|
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.
|
|
msg78404 - (view) |
Author: Antoine Pitrou (pitrou) |
Date: 2008-12-28 14:29 |
|
I've committed an improved patch, with tests and doc, in r67979 and
r67981. Thanks!
|
|
| Date |
User |
Action |
Args |
| 2008-12-28 14:29:38 | pitrou | set | status: open -> closed resolution: fixed messages:
+ msg78404 |
| 2008-12-27 21:05:37 | pitrou | set | nosy:
+ pitrou |
| 2008-11-27 14:07:41 | purcell | set | nosy:
+ purcell messages:
+ msg76500 |
| 2008-11-27 09:49:59 | dleonard0 | create | |
|