summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Finney <ben@benfinney.id.au>2008-05-16 16:50:38 +1000
committerBen Finney <ben@benfinney.id.au>2008-05-16 16:50:38 +1000
commitad7bc46acd80451de21ce58450edb0f4367a5c79 (patch)
tree12775f7901544a709f8d63079f1cd57fef00f5a8 /tests
parenta953d82143f0ec979e18f17e8d9bbacbac954868 (diff)
downloadpython-apt-ad7bc46acd80451de21ce58450edb0f4367a5c79.tar.gz
Fix code indentation to 4 spaces, to conform with PEP 8.
Diffstat (limited to 'tests')
-rw-r--r--tests/cache.py74
-rw-r--r--tests/depcache.py76
-rw-r--r--tests/lock.py6
-rwxr-xr-xtests/memleak.py54
-rw-r--r--tests/pkgproblemresolver.py110
-rw-r--r--tests/pkgrecords.py48
-rw-r--r--tests/pkgsrcrecords.py26
7 files changed, 197 insertions, 197 deletions
diff --git a/tests/cache.py b/tests/cache.py
index 34535e68..24732578 100644
--- a/tests/cache.py
+++ b/tests/cache.py
@@ -8,44 +8,44 @@ 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 Cache test on all packages:"
- # first, get all pkgs
- for pkg in cache.Packages:
- i += 1
- x = pkg.Name
- # then get each version
- for ver in pkg.VersionList:
- # get some version information
- a = ver.FileList
- b = ver.VerStr
- c = ver.Arch
- d = ver.DependsListStr
- dl = ver.DependsList
- # get all dependencies (a dict of string->list,
- # e.g. "depends:" -> [ver1,ver2,..]
- for dep in dl.keys():
- # get the list of each dependency object
- for depVerList in dl[dep]:
- for z in depVerList:
- # get all TargetVersions of
- # the dependency object
- for j in z.AllTargets():
- f = j.FileList
- g = ver.VerStr
- h = ver.Arch
- k = ver.DependsListStr
- j = ver.DependsList
- pass
+ apt_pkg.init()
+ cache = apt_pkg.GetCache()
+ depcache = apt_pkg.GetDepCache(cache)
+ depcache.Init()
+ i=0
+ all=cache.PackageCount
+ print "Running Cache test on all packages:"
+ # first, get all pkgs
+ for pkg in cache.Packages:
+ i += 1
+ x = pkg.Name
+ # then get each version
+ for ver in pkg.VersionList:
+ # get some version information
+ a = ver.FileList
+ b = ver.VerStr
+ c = ver.Arch
+ d = ver.DependsListStr
+ dl = ver.DependsList
+ # get all dependencies (a dict of string->list,
+ # e.g. "depends:" -> [ver1,ver2,..]
+ for dep in dl.keys():
+ # get the list of each dependency object
+ for depVerList in dl[dep]:
+ for z in depVerList:
+ # get all TargetVersions of
+ # the dependency object
+ for j in z.AllTargets():
+ f = j.FileList
+ g = ver.VerStr
+ h = ver.Arch
+ k = ver.DependsListStr
+ j = ver.DependsList
+ pass
- print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)),
+ print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)),
if __name__ == "__main__":
- main()
- sys.exit(0)
+ main()
+ sys.exit(0)
diff --git a/tests/depcache.py b/tests/depcache.py
index 635fea14..32c510f0 100644
--- a/tests/depcache.py
+++ b/tests/depcache.py
@@ -8,46 +8,46 @@ 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 (InstCount: %s)" % (x,depcache.InstCount)
- print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)),
+ 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 (InstCount: %s)" % (x,depcache.InstCount)
+ 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
+ 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
+ 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)
+ main()
+ sys.exit(0)
diff --git a/tests/lock.py b/tests/lock.py
index a3d962d7..aeab804b 100644
--- a/tests/lock.py
+++ b/tests/lock.py
@@ -21,7 +21,7 @@ if __name__ == "__main__":
apt_pkg.PkgSystemLock()
except SystemError, s:
print "Can't get lock: (error text:\n%s)" % s
- sys.exit(0)
+ sys.exit(0)
apt_pkg.PkgSystemUnLock()
@@ -35,7 +35,7 @@ if __name__ == "__main__":
# child
fd = apt_pkg.GetLock(lock,False)
print "Lockfile fd (child): %s" % fd
- sys.exit(0)
+ sys.exit(0)
# try to get lock with error flag
pid = os.fork()
@@ -43,4 +43,4 @@ if __name__ == "__main__":
# child
fd = apt_pkg.GetLock(lock,True)
print "Lockfile fd (child): %s" % fd
- sys.exit(0)
+ sys.exit(0)
diff --git a/tests/memleak.py b/tests/memleak.py
index 58a2f886..6eece9d4 100755
--- a/tests/memleak.py
+++ b/tests/memleak.py
@@ -11,36 +11,36 @@ cache = apt.Cache()
# memleak
for i in range(100):
- cache.open(None)
- print cache["apt"].name
- time.sleep(1)
- gc.collect()
- f = open("%s" % i,"w")
- for obj in gc.get_objects():
- f.write("%s\n" % str(obj))
- f.close()
+ cache.open(None)
+ print cache["apt"].name
+ time.sleep(1)
+ gc.collect()
+ f = open("%s" % i,"w")
+ for obj in gc.get_objects():
+ f.write("%s\n" % str(obj))
+ f.close()
# memleak
#for i in range(100):
-# cache = apt.Cache()
-# time.sleep(1)
-# cache = None
-# gc.collect()
+# cache = apt.Cache()
+# time.sleep(1)
+# cache = None
+# gc.collect()
# no memleak, but more or less the apt.Cache.open() code
for i in range(100):
- cache = apt_pkg.GetCache()
- depcache = apt_pkg.GetDepCache(cache)
- records = apt_pkg.GetPkgRecords(cache)
- list = apt_pkg.GetPkgSourceList()
- list.ReadMainList()
- dict = {}
- for pkg in cache.Packages:
- if len(pkg.VersionList) > 0:
- dict[pkg.Name] = apt.Package(cache,depcache,
- records, list, None, pkg)
-
- print cache["apt"]
- time.sleep(1)
-
- gc.collect()
+ cache = apt_pkg.GetCache()
+ depcache = apt_pkg.GetDepCache(cache)
+ records = apt_pkg.GetPkgRecords(cache)
+ list = apt_pkg.GetPkgSourceList()
+ list.ReadMainList()
+ dict = {}
+ for pkg in cache.Packages:
+ if len(pkg.VersionList) > 0:
+ dict[pkg.Name] = apt.Package(cache,depcache,
+ records, list, None, pkg)
+
+ print cache["apt"]
+ time.sleep(1)
+
+ gc.collect()
diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py
index 546e2f16..82186d40 100644
--- a/tests/pkgproblemresolver.py
+++ b/tests/pkgproblemresolver.py
@@ -8,63 +8,63 @@ 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.BrokenCount > 0:
- fixer = apt_pkg.GetPkgProblemResolver(depcache)
- fixer.Clear(pkg)
- fixer.Protect(pkg)
- # we first try to resolve the problem
- # with the package that should be installed
- # protected
- try:
- fixer.Resolve(True)
- except SystemError:
- # the pkg seems to be broken, the
- # returns a exception
- fixer.Clear(pkg)
- fixer.Resolve(True)
- if not depcache.MarkedInstall(pkg):
- print "broken in archive: %s " % pkg.Name
- fixer = None
- if depcache.InstCount == 0:
- if depcache.IsUpgradable(pkg):
- print "Error marking %s for install" % x
- for p in cache.Packages:
- if depcache.MarkedInstall(p) or depcache.MarkedUpgrade(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)),
+ 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.BrokenCount > 0:
+ fixer = apt_pkg.GetPkgProblemResolver(depcache)
+ fixer.Clear(pkg)
+ fixer.Protect(pkg)
+ # we first try to resolve the problem
+ # with the package that should be installed
+ # protected
+ try:
+ fixer.Resolve(True)
+ except SystemError:
+ # the pkg seems to be broken, the
+ # returns a exception
+ fixer.Clear(pkg)
+ fixer.Resolve(True)
+ if not depcache.MarkedInstall(pkg):
+ print "broken in archive: %s " % pkg.Name
+ fixer = None
+ if depcache.InstCount == 0:
+ if depcache.IsUpgradable(pkg):
+ print "Error marking %s for install" % x
+ for p in cache.Packages:
+ if depcache.MarkedInstall(p) or depcache.MarkedUpgrade(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
+ 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
+ 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)
+ main()
+ sys.exit(0)
diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py
index 308505f7..72096463 100644
--- a/tests/pkgrecords.py
+++ b/tests/pkgrecords.py
@@ -9,30 +9,30 @@ import sys
def main():
- apt_pkg.init()
- cache = apt_pkg.GetCache()
- depcache = apt_pkg.GetDepCache(cache)
- depcache.Init()
- i=0
- print "Running PkgRecords test on all packages:"
- for pkg in cache.Packages:
- i += 1
- records = apt_pkg.GetPkgRecords(cache)
- if len(pkg.VersionList) == 0:
- #print "no available version, cruft"
- continue
- version = depcache.GetCandidateVer(pkg)
- if not version:
- continue
- file, index = version.FileList.pop(0)
- if records.Lookup((file,index)):
- #print records.FileName
- x = records.FileName
- y = records.LongDesc
- pass
- print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)),
+ apt_pkg.init()
+ cache = apt_pkg.GetCache()
+ depcache = apt_pkg.GetDepCache(cache)
+ depcache.Init()
+ i=0
+ print "Running PkgRecords test on all packages:"
+ for pkg in cache.Packages:
+ i += 1
+ records = apt_pkg.GetPkgRecords(cache)
+ if len(pkg.VersionList) == 0:
+ #print "no available version, cruft"
+ continue
+ version = depcache.GetCandidateVer(pkg)
+ if not version:
+ continue
+ file, index = version.FileList.pop(0)
+ if records.Lookup((file,index)):
+ #print records.FileName
+ x = records.FileName
+ y = records.LongDesc
+ pass
+ print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)),
if __name__ == "__main__":
- main()
- sys.exit(0)
+ main()
+ sys.exit(0)
diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py
index 410140c8..3eb0fcab 100644
--- a/tests/pkgsrcrecords.py
+++ b/tests/pkgsrcrecords.py
@@ -9,19 +9,19 @@ import sys
def main():
- apt_pkg.init()
- cache = apt_pkg.GetCache()
- i=0
- print "Running PkgSrcRecords test on all packages:"
- for x in cache.Packages:
- i += 1
- src = apt_pkg.GetPkgSrcRecords()
- if src.Lookup(x.Name):
- #print src.Package
- pass
- print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)),
+ apt_pkg.init()
+ cache = apt_pkg.GetCache()
+ i=0
+ print "Running PkgSrcRecords test on all packages:"
+ for x in cache.Packages:
+ i += 1
+ src = apt_pkg.GetPkgSrcRecords()
+ if src.Lookup(x.Name):
+ #print src.Package
+ pass
+ print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)),
if __name__ == "__main__":
- main()
- sys.exit(0)
+ main()
+ sys.exit(0)