[Pkg-gnupg-commit] [gpgme] 100/132: python: Make tests more robust.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Apr 26 01:01:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gpgme.
commit ac4849953860547b06a167ca9612c4de369d02b6
Author: Justus Winter <justus at g10code.com>
Date: Tue Mar 14 11:08:08 2017 +0100
python: Make tests more robust.
* lang/python/tests/support.py (TemporaryDirectory): Always use our
own version even if 'tempfile.TemporaryDirectory' is provided, because
we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
tripping over gpg-agent deleting its own sockets.
Signed-off-by: Justus Winter <justus at g10code.com>
---
lang/python/tests/support.py | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/lang/python/tests/support.py b/lang/python/tests/support.py
index a381270..69aa7a4 100644
--- a/lang/python/tests/support.py
+++ b/lang/python/tests/support.py
@@ -78,17 +78,16 @@ def mark_key_trusted(ctx, key):
ctx.op_edit(key, Editor().edit, sink, sink)
-# Python2/3 compatibility
-if hasattr(tempfile, "TemporaryDirectory"):
- # Python3.2 and up
- TemporaryDirectory = tempfile.TemporaryDirectory
-else:
- class TemporaryDirectory(object):
- def __enter__(self):
- self.path = tempfile.mkdtemp()
- return self.path
- def __exit__(self, *args):
- shutil.rmtree(self.path)
+# Python3.2 and up has tempfile.TemporaryDirectory, but we cannot use
+# that, because there shutil.rmtree is used without
+# ignore_errors=True, and that races against gpg-agent deleting its
+# sockets.
+class TemporaryDirectory(object):
+ def __enter__(self):
+ self.path = tempfile.mkdtemp()
+ return self.path
+ def __exit__(self, *args):
+ shutil.rmtree(self.path, ignore_errors=True)
@contextlib.contextmanager
def EphemeralContext():
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list