Exit the loop when we don't have a package
When the system doesn't know about a package, then we know we need it. Attempting to check for version match leads to an error: TypeError: object of type 'NoneType' has no len() Go ahead and bail out once we know we don't have the package. Also added a test which triggers the error without the continue. Story: 2000955 Change-Id: Ib044b5de62aa09274054c3ff1d8e4cb860ba9a11
This commit is contained in:
parent
9f8e8121c1
commit
a9759e5c80
|
@ -205,6 +205,7 @@ class Depends(object):
|
|||
installed = self.platform.get_pkg_version(rule[0])
|
||||
if not installed:
|
||||
missing.add(rule[0])
|
||||
continue
|
||||
for operator, constraint in rule[2]:
|
||||
if not _eval(installed, operator, constraint):
|
||||
incompatible.append(
|
||||
|
|
|
@ -226,6 +226,17 @@ class TestDepends(TestCase):
|
|||
[('missing', ['foo'])], depends.check_rules([("foo", [], [])]))
|
||||
mock_depend_platform.assert_called_once_with("foo")
|
||||
|
||||
def test_check_rule_missing_version(self):
|
||||
depends = Depends("")
|
||||
depends.platform = mock.MagicMock()
|
||||
mock_depend_platform = self.useFixture(
|
||||
fixtures.MockPatchObject(depends.platform, 'get_pkg_version',
|
||||
return_value=None)).mock
|
||||
self.assertEqual(
|
||||
[('missing', ['foo'])],
|
||||
depends.check_rules([("foo", [], [(">=", "1.2.3")])]))
|
||||
mock_depend_platform.assert_called_once_with("foo")
|
||||
|
||||
def test_check_rule_present(self):
|
||||
depends = Depends("")
|
||||
depends.platform = mock.MagicMock()
|
||||
|
|
Loading…
Reference in New Issue