From 9840187c10dcac5953daa0b2b419a86e633d7a22 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 10 Sep 2020 14:16:56 +0200 Subject: test_openpgp: Fix race conditions in mocked system env cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- tests/test_openpgp.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/test_openpgp.py') diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 3eacc32..6bce97d 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -337,6 +337,7 @@ class MockedSystemGPGEnvironment(SystemGPGEnvironment): """System environment variant mocked to use isolated GNUPGHOME""" def __init__(self, *args, **kwargs): self._tmpdir = tempfile.TemporaryDirectory() + self._home = self._tmpdir.name os.environ['GNUPGHOME'] = self._tmpdir.name super().__init__(*args, **kwargs) @@ -348,6 +349,9 @@ class MockedSystemGPGEnvironment(SystemGPGEnvironment): def close(self): if self._tmpdir is not None: + IsolatedGPGEnvironment.close(self) + # we need to recreate it to make cleanup() happy + os.mkdir(self._tmpdir.name) self._tmpdir.cleanup() self._tmpdir = None os.environ.pop('GNUPGHOME', None) -- cgit v1.2.3