Robert Collins <robe...@robertcollins.net> added the comment: On Sun, 2009-04-05 at 07:25 +0000, Garrett Cooper wrote: > Garrett Cooper <yaneg...@gmail.com> added the comment: > > I think some perspective is required on this enhancement request. I > originally filed this issue -- http://bugs.python.org/issue5538 -- > because of the unneeded complexity involved with duplicating > teardown-related code in setUp because of a step in setUp failing.
Indeed, and in bzr and other unittest extension libraries one of the first things done is to make tearDown be called always. > >From my perspective, there are two issues: > > - setUp failing doesn't cleanup on failure unless the test writer > explicitly adds cleanup logic. the proposed patch in 5679 runs cleanups always, so this shouldn't be an issue with the addCleanup functionality. > - cleanup shouldn't partially replace tearDown -- either supplement it > or completely replace it longterm. Otherwise the unittest code and > expectations associated with it will potentially confuse end users. I'm conceptually fine with this, certainly I've not written a tearDown for tests in bzr in a very long time. > Another thought: Why not have an option for defining a method called > `incrementalTearDown', which replaces `tearDown' from a functional > standpoint? A method like that would clearly convey that this is > designed to replace tearDown, it's not the same functionally, and would > ease migration over the long-term if people chose to use this design > when writing testcases. Its much more complex than addCleanup [it will be tied to the MRO], not as flexible (and in big suites that starts to matter a lot), and unable to trivially hook into actually used resources [which addCleanup does]. -Rob ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5679> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com