From 5c5289c8810fd66867d890cf170d80997496203a Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Wed, 25 Oct 2017 14:03:19 +0200 Subject: openpgp: Fix and test the context manager API --- tests/test_openpgp.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index dc2eafc..88b105b 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -202,3 +202,23 @@ class OpenPGPNoKeyTest(unittest.TestCase): self.env.verify_file, f) except gemato.exceptions.OpenPGPNoImplementation as e: raise unittest.SkipTest(str(e)) + + +class OpenPGPContextManagerTest(unittest.TestCase): + """ + Test the context manager API for OpenPGPEnvironment. + """ + + def test_verify_manifest(self): + with io.BytesIO(SIGNED_MANIFEST.encode('utf8')) as f: + with gemato.openpgp.OpenPGPEnvironment() as env: + try: + try: + env.import_key( + io.BytesIO(PUBLIC_KEY.encode('utf8'))) + except RuntimeError: + raise unittest.SkipTest('Unable to import OpenPGP key') + + env.verify_file(f) + except gemato.exceptions.OpenPGPNoImplementation as e: + raise unittest.SkipTest(str(e)) -- cgit v1.2.3