Do not compare between None and int

In Python 2 comparison between int and None is allowed but in
Pyhton 3 it is not.

Example:

Pyhton 2

    >>> None > 0
    False

Python 3

    >>> None > 0
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: '>' not supported between instances of 'NoneType' and 'int'
This commit is contained in:
Radostin Stoyanov 2017-10-11 12:35:54 +01:00 committed by Cole Robinson
parent 75210ed37c
commit a2bcd6c43a
2 changed files with 3 additions and 2 deletions

View File

@ -181,7 +181,7 @@ def diff_compare(actual_out, filename=None, expect_out=None):
diff = "".join(difflib.unified_diff(expect_out.splitlines(1),
actual_out.splitlines(1),
fromfile=filename,
fromfile=filename or '',
tofile="Generated Output"))
if diff:
raise AssertionError("Conversion outputs did not match.\n%s" % diff)

View File

@ -187,7 +187,8 @@ class _SupportCheck(object):
actual_hv_version = conn.conn_version()
# Check that local libvirt version is sufficient
if _version_str_to_int(self.version) > actual_libvirt_version:
v = _version_str_to_int(self.version)
if v and (v > actual_libvirt_version):
return False
if self.hv_version: