Skip to content

use a cleaner pattern for temporary directory management in tests

This switches a pattern of:

  tmp = tempfile.mkdtemp()
  atexist.register(shutil.rmtree, tmp)
  ...

to:

  with tempfile.TemporaryDirectory() as tmp:
    ...

Apart from being less error prone, this also unconditionally cleans up the temporary directory, even when an uncaught exception is thrown.

I'll merge on 2020-08-29 if there are no objections.

Merge request reports