[issue5206] with context object for unittest assertRaises()

2009-02-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: Humph! The time machine strikes again. -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bu

[issue5206] with context object for unittest assertRaises()

2009-02-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: This is already done in trunk, you can use it as follows: with self.assertRaises(ZeroDivisionError): 1/0 -- nosy: +pitrou resolution: -> out of date status: open -> closed ___ Python tracker

[issue5206] with context object for unittest assertRaises()

2009-02-10 Thread Martin Blais
Changes by Martin Blais : -- components: +Library (Lib) type: -> feature request ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue5206] with context object for unittest assertRaises()

2009-02-10 Thread Martin Blais
New submission from Martin Blais : Here is a useful trick to restore the normal call syntax for delayed evaluation for assertRaises(): from contextlib import contextmanager @contextmanager def raised(exctype): try: yield raise AssertionError("Ex