[MERGE] TestCase.applyDeprecated

Andrew Bennetts andrew at canonical.com
Mon Sep 11 03:00:38 BST 2006


Robert Collins wrote:
> On Tue, 2006-09-05 at 18:04 -0500, John Arbash Meinel wrote:
[...]
> 
> > I know we have other tests for deprecated/not deprecated, and I don't
> > believe we need to catch AssertionError to do so.
> 
> The only catching of AssertError is done to ensure that we're getting a
> failure when we want one, in testing this helper.

It probably doesn't improve this case much, but if you want to test a TestCase's
failures without ever catching AssertionError, rather than this:

    self.assertRaises(AssertionError, self.do_something, ...)

you can do:

    test_case_being_tested = FooTestCase(...)
    test_case_being_tested.failureException = DummyError
    self.assertRaises(DummyError, test_case_being_tested.do_something, ...)

i.e. explicitly construct the TestCase class you're trying to test, so you can
override the failureException attribute on that instance.

The existing test looks readable enough to me, but this might be handy in
future.

-Andrew.





More information about the bazaar mailing list