diff options
Diffstat (limited to 'lang/python/tests')
-rw-r--r-- | lang/python/tests/support.py | 1 | ||||
-rwxr-xr-x | lang/python/tests/t-keylist.py | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lang/python/tests/support.py b/lang/python/tests/support.py index 4d7135e9..f1ffdc38 100644 --- a/lang/python/tests/support.py +++ b/lang/python/tests/support.py @@ -27,6 +27,7 @@ alpha = "A0FF4590BB6122EDEF6E3C542D727CC768697734" bob = "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2" encrypt_only = "F52770D5C4DB41408D918C9F920572769B9FE19C" sign_only = "7CCA20CCDE5394CEE71C9F0BFED153F12F18F45D" +no_such_key = "A" * 40 def make_filename(name): return os.path.join(os.environ['top_srcdir'], 'tests', 'gpg', name) diff --git a/lang/python/tests/t-keylist.py b/lang/python/tests/t-keylist.py index 5e8b3336..f7f6674e 100755 --- a/lang/python/tests/t-keylist.py +++ b/lang/python/tests/t-keylist.py @@ -20,6 +20,7 @@ from __future__ import absolute_import, print_function, unicode_literals del absolute_import, print_function, unicode_literals +import pyme from pyme import core, constants import support @@ -244,3 +245,25 @@ for i, key in enumerate(c.keylist()): if misc_check: misc_check (uids[0][0], key) + + +# check get_key() +with pyme.Context() as c: + c.get_key(support.alpha) + c.get_key(support.alpha, secret=True) + + c.get_key(support.bob) + try: + c.get_key(support.bob, secret=True) + except KeyError: + pass + else: + assert False, "Expected KeyError" + + # Legacy error + try: + c.get_key(support.no_such_key) + except pyme.errors.GPGMEError: + pass + else: + assert False, "Expected GPGMEError" |