dependencies: avoid Package-is-not-iterable in graph_reverse_depends doctest
authorW. Trevor King <wking@tremily.us>
Mon, 12 Nov 2012 02:45:38 +0000 (21:45 -0500)
committerW. Trevor King <wking@tremily.us>
Mon, 12 Nov 2012 02:48:45 +0000 (21:48 -0500)
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 "<doctest gentoolkit.dependencies.Dependencies.graph_reverse_depends[5]>", line 3, in <module>
        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 <genexpr>
        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

index 726d546173e41a7fc8fd6a9f1eecd01ff7b14d2f..3019a542ced9e2e7e1c2e55fb6d4fe06fd169b78 100644 (file)
@@ -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