[Python-Dev] Questions on unittest behaviour (original) (raw)

Collin Winter collinw at gmail.com
Sat Aug 19 19:06:17 CEST 2006


On 8/19/06, Nick Coghlan <ncoghlan at gmail.com> wrote:

Alternatively, someone who prefers your style (with a tearDown() method that can handle a partially executed call to the setUp() method), can just write it as:

def setUp(self) try: lockfile(testfile) # opensocket(), connecttodatabase(), etc somethingthatmayraiseanexception() except: self.tearDown() raise def tearDown(self): if fileislocked(testfile): unlockfile(testfile) Consider the parallel to PEP 343's enter and exit methods - exit is allowed to assume that it will only be called if enter succeeded, because that is part of the semantics of the with statement.

I can accept that.

Any thoughts on the other four items?

Collin Winter



More information about the Python-Dev mailing list