From d505769fd55daab8ed64534b000732a801f5b2fa Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 11 Nov 2012 21:45:38 -0500 Subject: [PATCH] dependencies: avoid Package-is-not-iterable in graph_reverse_depends doctest Dependency is a subclass of Query, so we need to initialize it with a CPV string, not a Package instance. The old doctest was raising: File ".../pym/gentoolkit/dependencies.py", line 202, in gentoolkit.dependencies.Dependencies.graph_reverse_depends Failed example: deptree = ffmpeg.graph_reverse_depends( only_direct=False, # Include indirect revdeps pkgset=installed) # from installed pkgset Exception raised: Traceback (most recent call last): File "/usr/lib/python3.2/doctest.py", line 1288, in __run compileflags, 1), test.globs) File "", line 3, in pkgset=installed) # from installed pkgset File ".../pym/gentoolkit/dependencies.py", line 237, in graph_reverse_depends pkgset = tuple(Dependencies(x) for x in pkgset) File ".../pym/gentoolkit/dependencies.py", line 237, in pkgset = tuple(Dependencies(x) for x in pkgset) File ".../pym/gentoolkit/dependencies.py", line 45, in __init__ Query.__init__(self, query) File "/home/wking/src/gentoolkit/pym/gentoolkit/query.py", line 51, in __init__ if not set(query).intersection(needed_chars): TypeError: 'Package' object is not iterable Also use ffmpeg-9999 (for better future-proofing) and update the length of the resulting deptree. --- pym/gentoolkit/dependencies.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py index 726d546..3019a54 100644 --- a/pym/gentoolkit/dependencies.py +++ b/pym/gentoolkit/dependencies.py @@ -192,18 +192,18 @@ class Dependencies(Query): Example usage: >>> from gentoolkit.dependencies import Dependencies - >>> ffmpeg = Dependencies('media-video/ffmpeg-0.5_p20373') + >>> ffmpeg = Dependencies('media-video/ffmpeg-9999') >>> # I only care about installed packages that depend on me: ... from gentoolkit.helpers import get_installed_cpvs >>> # I want to pass in a sorted list. We can pass strings or ... # Package or Atom types, so I'll use Package to sort: ... from gentoolkit.package import Package - >>> installed = sorted(Package(x) for x in get_installed_cpvs()) + >>> installed = sorted(get_installed_cpvs()) >>> deptree = ffmpeg.graph_reverse_depends( ... only_direct=False, # Include indirect revdeps ... pkgset=installed) # from installed pkgset >>> len(deptree) - 44 + 24 @type pkgset: iterable @keyword pkgset: sorted pkg cpv strings or anything sublassing -- 2.26.2