python: Skip tests if GnuPG is too old.
authorJustus Winter <justus@g10code.com>
Mon, 20 Mar 2017 15:00:13 +0000 (16:00 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 20 Mar 2017 15:20:02 +0000 (16:20 +0100)
* lang/python/tests/support.py (assert_gpg_version): New function.
* lang/python/tests/t-callbacks.py: Use the new function to skip the
test if GnuPG is too old.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-quick-key-creation.py: Likewise.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-key-signing.py: Likewise.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
lang/python/tests/support.py
lang/python/tests/t-callbacks.py
lang/python/tests/t-edit.py
lang/python/tests/t-encrypt-sym.py
lang/python/tests/t-quick-key-creation.py
lang/python/tests/t-quick-key-manipulation.py
lang/python/tests/t-quick-key-signing.py

index 80c3a4b..8f9d645 100644 (file)
@@ -26,6 +26,13 @@ import tempfile
 import time
 import gpg
 
+def assert_gpg_version(version=(2, 1, 0)):
+    with gpg.Context() as c:
+        if tuple(map(int, c.engine_info.version.split('.'))) < version:
+            print("GnuPG too old: have {0}, need {1}.".format(
+                c.engine_info.version, '.'.join(version)))
+            sys.exit(77)
+
 # known keys
 alpha = "A0FF4590BB6122EDEF6E3C542D727CC768697734"
 bob = "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2"
index ae15787..94cf11e 100755 (executable)
@@ -24,6 +24,8 @@ import os
 import gpg
 import support
 
+support.assert_gpg_version()
+
 c = gpg.Context()
 c.set_pinentry_mode(gpg.constants.PINENTRY_MODE_LOOPBACK)
 
index 7ac3626..ffc3296 100755 (executable)
@@ -26,6 +26,8 @@ import os
 import gpg
 import support
 
+support.assert_gpg_version()
+
 class KeyEditor(object):
     def __init__(self):
         self.steps = ["fpr", "expire", "1", "primary", "quit"]
index c15955a..8ee9cd6 100755 (executable)
@@ -24,6 +24,8 @@ import os
 import gpg
 import support
 
+support.assert_gpg_version()
+
 for passphrase in ("abc", b"abc"):
     c = gpg.Context()
     c.set_armor(True)
index c642c5b..8b7372e 100755 (executable)
@@ -25,6 +25,7 @@ import itertools
 import time
 
 import support
+support.assert_gpg_version((2, 1, 2))
 
 alpha = "Alpha <alpha@invalid.example.net>"
 
index 45e4c0e..0f47006 100755 (executable)
@@ -24,6 +24,7 @@ import os
 import gpg
 
 import support
+support.assert_gpg_version((2, 1, 14))
 
 alpha = "Alpha <alpha@invalid.example.net>"
 bravo = "Bravo <bravo@invalid.example.net>"
index f9778a3..3d648c5 100755 (executable)
@@ -25,6 +25,7 @@ import itertools
 import time
 
 import support
+support.assert_gpg_version((2, 1, 1))
 
 with support.EphemeralContext() as ctx:
     uid_counter = 0