Author r.david.murray
Recipients gruszczy, moyix, r.david.murray
Date 2011-04-07.00:47:44
SpamBayes Score 4.39134e-05
Marked as misclassified No
Message-id <1302137265.1.0.729096300689.issue11767@psf.upfronthosting.co.za>
In-reply-to
Content
get_file's promise is that what is returned is a file like object, so it not having a close() method would be an error.  So I don't think you need the try/except.  What I would suggest is to use the 'closing' context manager around the return statement.

As for tests, you could create a subclass with a custom get_file method that returns a mock object you can test to make sure the close method gets called, since Mailbox is the only place __getitem__ is defined.

Gah, I hit the wrong key an deleted your patch.  Reattaching.
History
Date User Action Args
2011-04-07 00:47:45r.david.murraysetrecipients: + r.david.murray, gruszczy, moyix
2011-04-07 00:47:45r.david.murraysetmessageid: <1302137265.1.0.729096300689.issue11767@psf.upfronthosting.co.za>
2011-04-07 00:47:44r.david.murraylinkissue11767 messages
2011-04-07 00:47:44r.david.murraycreate