summaryrefslogtreecommitdiff
path: root/src/leap/email/smtp/tests/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/email/smtp/tests/util.py')
-rw-r--r--src/leap/email/smtp/tests/util.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/leap/email/smtp/tests/util.py b/src/leap/email/smtp/tests/util.py
new file mode 100644
index 00000000..b62cb731
--- /dev/null
+++ b/src/leap/email/smtp/tests/util.py
@@ -0,0 +1,34 @@
+# copied from pygpgme's tests
+import os
+import shutil
+import tempfile
+import unittest
+
+import gpgme
+
+import smtprelay
+
+__all__ = ['GpgHomeTestCase']
+
+keydir = os.path.join(os.path.dirname(__file__), 'keys')
+
+class GpgHomeTestCase(unittest.TestCase):
+
+ gpg_conf_contents = ''
+ import_keys = []
+
+ def keyfile(self, key):
+ return open(os.path.join(keydir, key), 'rb')
+
+ def setUp(self):
+ self._gpghome = tempfile.mkdtemp(prefix='tmp.gpghome')
+
+ # import requested keys into the keyring
+ ctx = gpgme.Context()
+ for key in self.import_keys:
+ with self.keyfile(key) as fp:
+ ctx.import_(fp)
+
+ def tearDown(self):
+ del os.environ['GNUPGHOME']
+ shutil.rmtree(self._gpghome, ignore_errors=True)