diff options
author | Michał Górny <mgorny@gentoo.org> | 2020-09-10 14:16:56 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2020-09-10 14:16:56 +0200 |
commit | 9840187c10dcac5953daa0b2b419a86e633d7a22 (patch) | |
tree | f585cd5fd18e076b4967a57793d49c9fcc03adfd /tests/test_openpgp.py | |
parent | 15b5cf264909404ecc7705cfe0a238f5302179f0 (diff) | |
download | gemato-9840187c10dcac5953daa0b2b419a86e633d7a22.tar.gz |
test_openpgp: Fix race conditions in mocked system env cleanup
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'tests/test_openpgp.py')
-rw-r--r-- | tests/test_openpgp.py | 4 |
1 files changed, 4 insertions, 0 deletions
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) |