diff options
author | Michael Hudson <michael.hudson@linaro.org> | 2010-12-15 12:18:11 +1300 |
---|---|---|
committer | Michael Hudson <michael.hudson@linaro.org> | 2010-12-15 12:18:11 +1300 |
commit | be1862420af2f026ece3f9052d271ed157666bca (patch) | |
tree | 6fa94ffd80c9d700724ecd2ea474161c28ade350 /hwpack | |
parent | 0d4860aeaa5626e8e249bf7bed5072e8dce71e2d (diff) | |
parent | 885d12b531a474ecad84ae1f01e567e6d75bb676 (diff) |
hwpack.packages.stringify_relationship handles 'strictly less/greater than' relationships correctly
Diffstat (limited to 'hwpack')
-rw-r--r-- | hwpack/packages.py | 11 | ||||
-rw-r--r-- | hwpack/tests/test_packages.py | 38 |
2 files changed, 45 insertions, 4 deletions
diff --git a/hwpack/packages.py b/hwpack/packages.py index ae6a452..a76d4b7 100644 --- a/hwpack/packages.py +++ b/hwpack/packages.py @@ -79,9 +79,14 @@ def stringify_relationship(pkg, relationship): for or_alternative in or_dep.or_dependencies: suffix = "" if or_alternative.relation: - suffix = " (%s %s)" % ( - or_alternative.relation, - or_alternative.version) + relation = or_alternative.relation + if relation in ('<', '>'): + # The choice made here by python-apt is to report the + # relationship in a Python spelling; as far as apt + # knows, < is a deprecated spelling of <=; << is the + # spelling of "strictly less than". Similarly for >. + relation *= 2 + suffix = " (%s %s)" % (relation, or_alternative.version) or_list.append("%s%s" % (or_alternative.name, suffix)) relationship_list.append(" | ".join(or_list)) relationship_str = ", ".join(relationship_list) diff --git a/hwpack/tests/test_packages.py b/hwpack/tests/test_packages.py index 386232e..d0aedc4 100644 --- a/hwpack/tests/test_packages.py +++ b/hwpack/tests/test_packages.py @@ -156,7 +156,7 @@ class StringifyRelationshipTests(TestCaseWithFixtures): self.assertEqual( "bar | baz", stringify_relationship(candidate, "Depends")) - def test_package_with_version(self): + def test_package_with_le(self): target_package = DummyFetchedPackage( "foo", "1.0", depends="baz (<= 2.0)") source = self.useFixture(AptSourceFixture([target_package])) @@ -165,6 +165,42 @@ class StringifyRelationshipTests(TestCaseWithFixtures): self.assertEqual( "baz (<= 2.0)", stringify_relationship(candidate, "Depends")) + def test_package_with_lt(self): + target_package = DummyFetchedPackage( + "foo", "1.0", depends="baz (<< 2.0)") + source = self.useFixture(AptSourceFixture([target_package])) + with IsolatedAptCache([source.sources_entry]) as cache: + candidate = cache.cache['foo'].candidate + self.assertEqual( + "baz (<< 2.0)", stringify_relationship(candidate, "Depends")) + + def test_package_with_eq(self): + target_package = DummyFetchedPackage( + "foo", "1.0", depends="baz (= 2.0)") + source = self.useFixture(AptSourceFixture([target_package])) + with IsolatedAptCache([source.sources_entry]) as cache: + candidate = cache.cache['foo'].candidate + self.assertEqual( + "baz (= 2.0)", stringify_relationship(candidate, "Depends")) + + def test_package_with_gt(self): + target_package = DummyFetchedPackage( + "foo", "1.0", depends="baz (>> 2.0)") + source = self.useFixture(AptSourceFixture([target_package])) + with IsolatedAptCache([source.sources_entry]) as cache: + candidate = cache.cache['foo'].candidate + self.assertEqual( + "baz (>> 2.0)", stringify_relationship(candidate, "Depends")) + + def test_package_with_ge(self): + target_package = DummyFetchedPackage( + "foo", "1.0", depends="baz (>= 2.0)") + source = self.useFixture(AptSourceFixture([target_package])) + with IsolatedAptCache([source.sources_entry]) as cache: + candidate = cache.cache['foo'].candidate + self.assertEqual( + "baz (>= 2.0)", stringify_relationship(candidate, "Depends")) + class PackageMakerTests(TestCaseWithFixtures): |