On Fri, Feb 15, 2019 at 11:44 AM Steve Dower <steve.dower at python.org> wrote: > That said, I'd love to have a context manager that we can use to make > this easier. Really, none of us should be having to decide "how am I > going to use a temporary location on the file system in my test", > because we should have one obvious (and easy!) way to do it. I found an old rejected issue [1] for adding a `tmpdir` method to unittest.TestCase, which is actually a solution that we've independently developed and use frequently for work. It basically works by registering a cleanup function before returning the path to the temporary directory, so you just call `self.tmpdir()`, use the path, forget about cleanup, and don't lose a level of indentation to a context manager. I think it would be worthwhile to reconsider this addition to unittest, or add it as a standard base test class in test.support (though either way it would need a cleaner and more robust implementation than is offered in that issue). [1] https://bugs.python.org/issue2156 -- Zach
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4