From 476b97822b169c30cc246c1de2ff94cf89084706 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 16 Feb 2017 14:53:11 +0100 Subject: 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 --- lang/python/tests/support.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lang/python/tests/support.py') 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) -- cgit v1.2.3