diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-05-27 12:26:34 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-05-27 12:26:34 +0000 |
| commit | 63cfbd9034757cd89d7310dfd9fdaa170bbfa19a (patch) | |
| tree | c70f1d5b594b58c6b3b3f58a08ef8ef93ee4a107 /tests | |
| parent | 58fad74365c97bd88e89b0d3b310d88b89e03c13 (diff) | |
| download | python-apt-63cfbd9034757cd89d7310dfd9fdaa170bbfa19a.tar.gz | |
* tests/depcache.py added that tests various bits of the depcache
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cache.py | 3 | ||||
| -rw-r--r-- | tests/depcache.py | 52 |
2 files changed, 53 insertions, 2 deletions
diff --git a/tests/cache.py b/tests/cache.py index e0cbb95c..47d9a3b4 100644 --- a/tests/cache.py +++ b/tests/cache.py @@ -1,7 +1,6 @@ #!/usr/bin/env python2.4 # -# Test for the PkgSrcRecords code -# it segfaults for python-apt < 0.5.37 +# Test for the pkgCache code # import apt_pkg diff --git a/tests/depcache.py b/tests/depcache.py new file mode 100644 index 00000000..f5deed33 --- /dev/null +++ b/tests/depcache.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python2.4 +# +# Test for the DepCache code +# + +import apt_pkg +import sys + +def main(): + apt_pkg.init() + cache = apt_pkg.GetCache() + depcache = apt_pkg.GetDepCache(cache) + depcache.Init() + i=0 + all=cache.PackageCount + print "Running DepCache test on all packages" + print "(trying to install each and then mark it keep again):" + # first, get all pkgs + for pkg in cache.Packages: + i += 1 + x = pkg.Name + # then get each version + ver =depcache.GetCandidateVer(pkg) + if ver != None: + depcache.MarkInstall(pkg) + if depcache.InstCount == 0: + if depcache.IsUpgradable(pkg): + print "Error marking %s for install" % x + for p in cache.Packages: + if depcache.MarkedInstall(p): + depcache.MarkKeep(p) + if depcache.InstCount != 0: + print "Error undoing the selection for %s" % x + print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)), + + print + print "Trying Upgrade:" + depcache.Upgrade() + print "To install: %s " % depcache.InstCount + print "To remove: %s " % depcache.DelCount + print "Kept back: %s " % depcache.KeepCount + + print "Trying DistUpgrade:" + depcache.Upgrade(True) + print "To install: %s " % depcache.InstCount + print "To remove: %s " % depcache.DelCount + print "Kept back: %s " % depcache.KeepCount + + +if __name__ == "__main__": + main() + sys.exit(0) |
