On 14/02/2019 14:56, Giampaolo Rodola' wrote:
On Thu, Feb 14, 2019 at 3:25 PM Eric Snow <[email protected] <mailto:[email protected]>> wrote:On Thu, Feb 14, 2019, 02:47 Ronald Oussoren via Python-Dev <[email protected] <mailto:[email protected]> wrote: I usually use shutil.rmtree for tests that need to create temporary files, and create a temporary directory for those files (that is, use tempfile.mkdtemp in setUp() and use shutil.rmtree in tearDown()). That way I don’t have to adjust house-keeping code when I make changes to test code. Same here. -ericWhat I generally do is avoid relying on tempfile.mkdtemp() and always use TESTFN instead. I think it's cleaner as a pradigm because it's an incentive to not pollute the single unit tests with `self.addCleanup()` instructions (the whole cleanup logic is always supposed to occur in setUp/tearDown):
Must chime in here because I've been pushing (variously months & years ago) to move *away* from TESTFN because it generates numerous intermittent errors on my Windows setup. I've had several goes at starting to do that but a combination of my own lack of time plus some people's reluctance to go that route altogether has stalled the thing.
I'm not sure I understand the difference in cleanup/teardown terms between using tempfile and using TESTFN. The objections I've seen from people (apart, obviously, from test churn) are to do with building up testing temp artefacts on a possibly low-sized disk.
TJG _______________________________________________ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
