Fix compiled version check

Fixes #2412
This commit is contained in:
Florian Bruhin 2017-03-07 22:04:54 +01:00
parent 4c3c86081f
commit 7c9d004bbc
2 changed files with 7 additions and 1 deletions

View File

@ -88,9 +88,12 @@ def version_check(version, op=operator.ge, strict=False):
op: The operator to use for the check.
strict: If given, also check the compiled Qt version.
"""
if strict:
assert op in [operator.ge, operator.lt], op
parsed = pkg_resources.parse_version(version)
result = op(pkg_resources.parse_version(qVersion()), parsed)
if result and strict:
if ((strict and op == operator.ge and result) or
(strict and op == operator.lt and not result)):
result = op(pkg_resources.parse_version(QT_VERSION_STR), parsed)
return result

View File

@ -52,6 +52,9 @@ import overflow_test_cases
# strict=True
('5.4.0', '5.3.0', '5.4.0', operator.ge, False),
('5.4.0', '5.4.0', '5.4.0', operator.ge, True),
('5.4.0', '5.3.0', '5.4.0', operator.lt, True),
('5.4.0', '5.4.0', '5.4.0', operator.lt, False),
])
def test_version_check(monkeypatch, qversion, compiled, version, op, expected):
"""Test for version_check().