tests: use context manager and/or standard setup temp files

This commit is contained in:
Jochen Sprickerhof 2022-11-22 17:17:45 +01:00 committed by Hans-Christoph Steiner
parent 1eeb992118
commit d29a486e31
12 changed files with 465 additions and 680 deletions

View file

@ -17,6 +17,7 @@
import os
import sys
import tempfile
class TmpCwd():
@ -58,3 +59,10 @@ def mock_open_to_str(mock):
return "".join([
x.args[0] for x in mock.mock_calls if str(x).startswith("call().write(")
])
def mkdtemp():
if sys.version_info < (3, 10): # ignore_cleanup_errors was added in 3.10
return tempfile.TemporaryDirectory()
else:
return tempfile.TemporaryDirectory(ignore_cleanup_errors=True)