Re: [Python-Dev] Explicitly declaring expected exceptions for ablock

2005-06-21 Thread Dmitry Dvoinikov
> try: > c().foo() > except TypeError: > pass > else: > assert False, "c.foo() should have thrown TypeError" In fact, the above code actually expects foo to throw particular exception, not exactly the same as the original requirement. More of expect TypeError: c().foo() and s

Re: [Python-Dev] Explicitly declaring expected exceptions for ablock

2005-06-21 Thread Dmitry Dvoinikov
> I suspect that you wanted either: >try: >c().foo() >fail('Should have raised TypeError') >except TypeError: >pass # expected Right, of course I use something along these lines: try: c().foo() except TypeError: pass else: assert False, "c.foo() shoul

Re: [Python-Dev] Explicitly declaring expected exceptions for ablock

2005-06-21 Thread Michael Chermside
Dmitry Dvoinikov writes: > The reason for that being self-tests with lots and lots of > little code snippets like this: > > try: > c().foo() > except TypeError: > pass Paul Du Boise already responded explaining that PEP 343 probably handles the task you want. I just wanted to mention that