aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/support.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2017-02-16 13:53:11 +0000
committerJustus Winter <[email protected]>2017-02-16 15:43:10 +0000
commit476b97822b169c30cc246c1de2ff94cf89084706 (patch)
treea11b21e34c3f414a5524e353083faaa7c6ba25ad /lang/python/tests/support.py
parentpython: Fix passphrase callback wrapping. (diff)
downloadgpgme-476b97822b169c30cc246c1de2ff94cf89084706.tar.gz
gpgme-476b97822b169c30cc246c1de2ff94cf89084706.zip
python: Support quick key creation.
* NEWS: Update. * lang/python/gpg/constants/__init__.py: Import new file. * lang/python/gpg/constants/create.py: New file. * lang/python/gpg/core.py (Context.create_key): New function. * lang/python/tests/Makefile.am (XTESTS): Add new test. * lang/python/tests/support.py (TemporaryDirectory): New class. * lang/python/tests/t-quick-key-creation.py: New file. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/tests/support.py')
-rw-r--r--lang/python/tests/support.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/python/tests/support.py b/lang/python/tests/support.py
index 0b04bb6f..ed5bf615 100644
--- a/lang/python/tests/support.py
+++ b/lang/python/tests/support.py
@@ -20,6 +20,7 @@ del absolute_import, print_function, unicode_literals
import sys
import os
+import tempfile
import gpg
# known keys
@@ -72,3 +73,17 @@ def mark_key_trusted(ctx, key):
return result
with gpg.Data() as sink:
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):
+ import shutil
+ shutil.rmtree(self.path)