On 8/19/06, Nick Coghlan <[EMAIL PROTECTED]> 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:
>           lock_file(testfile) # open_socket(), connect_to_database(), etc
>           something_that_may_raise_an_exception()
>       except:
>           self.tearDown()
>           raise
>
>   def tearDown(self):
>       if file_is_locked(testfile):
>           unlock_file(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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to