diff options
| -rw-r--r-- | apt/package.py | 3 | ||||
| -rw-r--r-- | debian/changelog | 3 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 11 |
3 files changed, 17 insertions, 0 deletions
diff --git a/apt/package.py b/apt/package.py index 4104f93e..cb373c2e 100644 --- a/apt/package.py +++ b/apt/package.py @@ -707,6 +707,9 @@ class Package(object): return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name, self._pkg.architecture, self._pkg.id) + def __cmp__(self, other): + return cmp(self.name, other.name) + def candidate(self): """Return the candidate version of the package. diff --git a/debian/changelog b/debian/changelog index 0864d725..b7876e51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,9 @@ python-apt (0.8.1) UNRELEASED; urgency=low that needs universe enabled as well (plus add test) * apt/progress/gtk2.py: - update to the latest vte API for child-exited (LP: #865388) + * tests/test_apt_cache.py: + - add __cmp__ to apt.Package so that sort() sorts by name + on list of package objects -- Julian Andres Klode <jak@debian.org> Tue, 07 Jun 2011 14:00:22 +0200 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 2f812059..9c1f549f 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -181,5 +181,16 @@ class TestAptCache(unittest.TestCase): apt_pkg.config.set("dir::etc::sourcelist", old_source_list) apt_pkg.config.set("dir::etc::sourceparts", old_source_parts) + def test_package_cmp(self): + cache = apt.Cache() + l = [] + l.append(cache["libc6"]) + l.append(cache["xterm"]) + l.append(cache["apt"]) + l.sort() + self.assertEqual([p.name for p in l], + ["apt", "libc6", "xterm"]) + + if __name__ == "__main__": unittest.main() |
