diff options
author | drebs <drebs@leap.se> | 2012-11-28 19:29:10 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2012-11-28 19:29:10 -0200 |
commit | a59886ce1727162ad8992fdabcc38137760a8ab4 (patch) | |
tree | 59ef40afa08863936220a2fae220128a2ddc07b4 /src/leap/email/smtp/tests/util.py | |
parent | 4539d448f2537a7221a4658a2d9771d2e2db4120 (diff) |
creating test files (no tests yet)
Diffstat (limited to 'src/leap/email/smtp/tests/util.py')
-rw-r--r-- | src/leap/email/smtp/tests/util.py | 34 |
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) |