Message133186
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. |
|
| Date |
User |
Action |
Args |
| 2011-04-07 00:47:45 | r.david.murray | set | recipients:
+ r.david.murray, gruszczy, moyix |
| 2011-04-07 00:47:45 | r.david.murray | set | messageid: <[email protected]> |
| 2011-04-07 00:47:44 | r.david.murray | link | issue11767 messages |
| 2011-04-07 00:47:44 | r.david.murray | create | |
|