python: Fix version check.

* lang/python/tests/support.py (assert_gpg_version): Cope with
non-released versions.

Fixes-commit: e1cf8bab31
Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2017-03-20 16:53:29 +01:00
parent 16b202d999
commit 57e64d019d
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020

View File

@ -22,13 +22,15 @@ import contextlib
import shutil
import sys
import os
import re
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:
clean_version = re.match(r'\d+\.\d+\.\d+', c.engine_info.version).group(0)
if tuple(map(int, clean_version.split('.'))) < version:
print("GnuPG too old: have {0}, need {1}.".format(
c.engine_info.version, '.'.join(version)))
sys.exit(77)