[MERGE][1.2?][Bug #137823] Don't blindly raise UnavailableFeature during test setup

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Feb 11 07:46:18 GMT 2008


>>>>> "robert" == Robert Collins <robertc at robertcollins.net> writes:

    robert> On Sun, 2008-02-10 at 23:49 +0100, Vincent Ladeuil wrote:
    >> >>>>> "john" == John Arbash Meinel <john at arbash-meinel.com> writes:
    >> 
    john> Vincent Ladeuil wrote:
    >> >> Hi,
    >> >> 
    >> >> This bug was nasty, see details on https://bugs.edge.launchpad.net/bzr/+bug/137823
    >> >> 
    >> >> The risk of broking anything is sufficiently low that this may be
    >> >> included in 1.2 if time permits.
    >> >> 
    >> >> Also note that this was caused by an unusual way to check the
    >> >> availability of the feature, it needed to be done in
    >> >> transport.ftp.get_test_permutations() with no access to the test
    >> >> itself (hence no access to neither _test_needs_features nor
    >> >> requireFeature()).
    >> >> 
    >> >> Vincent
    >> 
    john> Why not change it so that raising an exception during
    john> setUp still calls tearDown?
    >> 
    >> You mean change the way a test is run ?
    >> 
    >> Because:
    >> 
    >> 1) unittest.TestCase.run don't do it, and I'll wait to have some
    >> more years of TDD experience before going against such a
    >> decision ;-)
    >> 
    >> 2) It was easier that way :)
    >> 
    >> 3) I wanted to address that bug only.

    robert> 4) teardown's are nearly all written on the assumption that setup
    robert> completed correctly.

Thanks, couldn't find the right words, I turn you 4) into
1). That was my primary concern. A lot of things can go wrong
during tearDown if setUp didn't complete correctly.

And http://docs.python.org/lib/testcase-objects.html says it
explicitly anyway:

,----
| tearDown(  	)
| 
<...>
|     This method will only be called if the setUp() succeeds,
|     regardless of the outcome of the test method. The default
|     implementation does nothing.
`----

Exceptions during setUp or tearDown are *errors*, we chose to
consider tests needing unavailable features like passing tests,
we can't achieve that by throwing exceptions during setUp.

   Vincent

P.S.: Don't forget to vote ;-)



More information about the bazaar mailing list