summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/package.py3
-rw-r--r--debian/changelog4
-rw-r--r--tests/test_apt_cache.py4
3 files changed, 9 insertions, 2 deletions
diff --git a/apt/package.py b/apt/package.py
index e09acca4..ab692788 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -107,6 +107,9 @@ class Dependency(object):
def __repr__(self):
return repr(self.or_dependencies)
+ def __iter__(self):
+ return self.or_dependencies.__iter__()
+
class DeprecatedProperty(property):
"""A property which gives DeprecationWarning on access.
diff --git a/debian/changelog b/debian/changelog
index afffdf12..7d939702 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,10 @@ python-apt (0.8.2) UNRELEASED; urgency=low
(LP: #885895)
* apt/package.py:
- add new "suggests" property, thanks to Christop Groth
+ - allow Dependency object to be iteratable, this allows to write
+ code like:
+ for or_dep_group in pkg.candidate.dependencies:
+ for dep in or_dep_group: do_something()
[ Tshepang Lekhonkhobe ]
* rm usage of camelcase in cache.py doc (closes: #626617)
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 0d80f617..7784a25f 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -55,8 +55,8 @@ class TestAptCache(unittest.TestCase):
# that is possible and does not crash
for pkg in cache:
if pkg.candidate:
- for or_dep in pkg.candidate.dependencies:
- for dep in or_dep.or_dependencies:
+ for or_deps in pkg.candidate.dependencies:
+ for dep in or_deps:
self.assertTrue(dep.name)
self.assertTrue(isinstance(dep.relation, str))
self.assertTrue(dep.pre_depend in (True, False))