From 8413810c46f802490280b0be1beebaaadf1aa9f2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 14 Apr 2009 00:47:23 +0200 Subject: * Remove any trailing whitespace --- tests/getcache_mem_corruption.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py index 42e9af00..c3f6eff3 100644 --- a/tests/getcache_mem_corruption.py +++ b/tests/getcache_mem_corruption.py @@ -6,16 +6,16 @@ import re import unittest class TestGetCache(unittest.TestCase): - + def setUp(self): apt_pkg.InitConfig() apt_pkg.InitSystem() - + def testWrongInvocation(self): # wrongly invoke GetCache() rather than GetDepCache() apt_cache = apt_pkg.GetCache() self.assertRaises(ValueError, apt_pkg.GetCache, apt_cache) - + def testProperInvocation(self): apt_cache = apt_pkg.GetCache(apt.progress.OpTextProgress()) apt_depcache = apt_pkg.GetDepCache(apt_cache) -- cgit v1.2.3 From d19943ea8489e06a1f5cd0bd545e0a0aeb4b8551 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 19 Apr 2009 17:30:57 +0200 Subject: * Update the code to use the new classes. --- apt/cache.py | 22 +++++++++++----------- apt/cdrom.py | 2 +- apt/debfile.py | 6 +++--- apt/package.py | 22 +++++++++++----------- doc/examples/acquire.py | 26 +++++++++++++------------- doc/examples/action.py | 4 ++-- doc/examples/build-deps.py | 8 ++++---- doc/examples/cdrom.py | 2 +- doc/examples/checkstate.py | 2 +- doc/examples/config.py | 2 +- doc/examples/configisc.py | 2 +- doc/examples/deb_inspect.py | 2 +- doc/examples/depcache.py | 4 ++-- doc/examples/desc.py | 6 +++--- doc/examples/indexfile.py | 6 +++--- doc/examples/metaindex.py | 2 +- doc/examples/print_uris.py | 2 +- doc/examples/recommends.py | 2 +- doc/examples/sources.py | 6 +++--- doc/examples/tagfile.py | 2 +- doc/source/examples/cache-packages.py | 2 +- doc/source/examples/cache-pkgfile.py | 2 +- doc/source/examples/missing-deps.py | 2 +- tests/cache.py | 4 ++-- tests/depcache.py | 4 ++-- tests/getcache_mem_corruption.py | 8 ++++---- tests/memleak.py | 8 ++++---- tests/pkgproblemresolver.py | 6 +++--- tests/pkgrecords.py | 6 +++--- tests/pkgsrcrecords.py | 4 ++-- 30 files changed, 88 insertions(+), 88 deletions(-) (limited to 'tests') diff --git a/apt/cache.py b/apt/cache.py index 05d8d1a9..60fd6553 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -78,10 +78,10 @@ class Cache(object): if progress is None: progress = apt.progress.OpProgress() self._run_callbacks("cache_pre_open") - self._cache = apt_pkg.GetCache(progress) - self._depcache = apt_pkg.GetDepCache(self._cache) - self._records = apt_pkg.GetPkgRecords(self._cache) - self._list = apt_pkg.GetPkgSourceList() + self._cache = apt_pkg.Cache(progress) + self._depcache = apt_pkg.DepCache(self._cache) + self._records = apt_pkg.PackageRecords(self._cache) + self._list = apt_pkg.SourceList() self._list.ReadMainList() self._set = set() self._weakref = weakref.WeakValueDictionary() @@ -154,8 +154,8 @@ class Cache(object): @property def required_download(self): """Get the size of the packages that are required to download.""" - pm = apt_pkg.GetPackageManager(self._depcache) - fetcher = apt_pkg.GetAcquire() + pm = apt_pkg.PackageManager(self._depcache) + fetcher = apt_pkg.Acquire() pm.GetArchives(fetcher, self._list, self._records) return fetcher.FetchNeeded @@ -270,7 +270,7 @@ class Cache(object): def install_archives(self, pm, install_progress): """ The first parameter *pm* refers to an object returned by - apt_pkg.GetPackageManager(). + apt_pkg.PackageManager(). The second parameter *install_progress* refers to an InstallProgress() object of the module apt.progress. @@ -309,8 +309,8 @@ class Cache(object): if install_progress is None: install_progress = apt.progress.InstallProgress() - pm = apt_pkg.GetPackageManager(self._depcache) - fetcher = apt_pkg.GetAcquire(fetch_progress) + pm = apt_pkg.PackageManager(self._depcache) + fetcher = apt_pkg.Acquire(fetch_progress) while True: # fetch archives first res = self._fetch_archives(fetcher, pm) @@ -494,8 +494,8 @@ def _test(): if not os.path.exists(dir): os.mkdir(dir) apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest") - pm = apt_pkg.GetPackageManager(cache._depcache) - fetcher = apt_pkg.GetAcquire(apt.progress.TextFetchProgress()) + pm = apt_pkg.PackageManager(cache._depcache) + fetcher = apt_pkg.Acquire(apt.progress.TextFetchProgress()) cache._fetch_archives(fetcher, pm) #sys.exit(1) diff --git a/apt/cdrom.py b/apt/cdrom.py index 907ac622..b9625ebf 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -45,7 +45,7 @@ class Cdrom(object): """ def __init__(self, progress=None, mountpoint=None, nomount=True): - self._cdrom = apt_pkg.GetCdrom() + self._cdrom = apt_pkg.Cdrom() if progress is None: self._progress = CdromProgress() else: diff --git a/apt/debfile.py b/apt/debfile.py index c60fc92d..6e4adb39 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -57,7 +57,7 @@ class DebPackage(object): "missing '%s' member" % "debian-binary")) control = apt_inst.debExtractControl(open(self.filename)) - self._sections = apt_pkg.ParseSection(control) + self._sections = apt_pkg.TagSection(control) self.pkgname = self._sections["Package"] def __getitem__(self, key): @@ -357,7 +357,7 @@ class DebPackage(object): """Satisfy the dependencies.""" # turn off MarkAndSweep via a action group (if available) try: - _actiongroup = apt_pkg.GetPkgActionGroup(self._cache._depcache) + _actiongroup = apt_pkg.ActionGroup(self._cache._depcache) except AttributeError: pass # check depends @@ -458,7 +458,7 @@ class DscSrcPackage(DebPackage): conflicts_tags = ["Build-Conflicts", "Build-Conflicts-Indep"] fobj = open(file) - tagfile = apt_pkg.ParseTagFile(fobj) + tagfile = apt_pkg.TagFile(fobj) sec = tagfile.Section try: while tagfile.Step() == 1: diff --git a/apt/package.py b/apt/package.py index 411f9635..3dbdf058 100644 --- a/apt/package.py +++ b/apt/package.py @@ -158,7 +158,7 @@ class Record(Mapping): """ def __init__(self, record_str): - self._rec = apt_pkg.ParseSection(record_str) + self._rec = apt_pkg.TagSection(record_str) def __hash__(self): return hash(self._rec) @@ -448,9 +448,9 @@ class Version(object): if _file_is_same(destfile, self.size, self._records.MD5Hash): print 'Ignoring already existing file:', destfile return - acq = apt_pkg.GetAcquire(progress or apt.progress.TextFetchProgress()) - apt_pkg.GetPkgAcqFile(acq, self.uri, self._records.MD5Hash, self.size, - base, destFile=destfile) + acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) + apt_pkg.AcquireFile(acq, self.uri, self._records.MD5Hash, self.size, + base, destfile=destfile) acq.Run() for item in acq.Items: if item.Status != item.StatDone: @@ -474,8 +474,8 @@ class Version(object): If *unpack* is ``True``, the path to the extracted directory is returned. Otherwise, the path to the .dsc file is returned. """ - src = apt_pkg.GetPkgSrcRecords() - acq = apt_pkg.GetAcquire(progress or apt.progress.TextFetchProgress()) + src = apt_pkg.SourceRecords() + acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) dsc = None src.Lookup(self.package.name) @@ -497,8 +497,8 @@ class Version(object): continue finally: fobj.close() - apt_pkg.GetPkgAcqFile(acq, src.Index.ArchiveURI(path), md5, size, - base, destFile=destfile) + apt_pkg.AcquireFile(acq, src.Index.ArchiveURI(path), md5, size, + base, destfile=destfile) acq.Run() for item in acq.Items: @@ -879,7 +879,7 @@ class Package(object): # this feature only works if the correct deb-src are in the # sources.list # otherwise we fall back to the binary version number - src_records = apt_pkg.GetPkgSrcRecords() + src_records = apt_pkg.SourceRecords() src_rec = src_records.Lookup(src_pkg) if src_rec: src_ver = src_records.Version @@ -1016,7 +1016,7 @@ class Package(object): self._pcache._depcache.MarkDelete(self._pkg, purge) # try to fix broken stuffsta if auto_fix and self._pcache._depcache.BrokenCount > 0: - fix = apt_pkg.GetPkgProblemResolver(self._pcache._depcache) + fix = apt_pkg.ProblemResolver(self._pcache._depcache) fix.Clear(self._pkg) fix.Protect(self._pkg) fix.Remove(self._pkg) @@ -1043,7 +1043,7 @@ class Package(object): self._pcache._depcache.MarkInstall(self._pkg, auto_inst, from_user) # try to fix broken stuff if auto_fix and self._pcache._depcache.BrokenCount > 0: - fixer = apt_pkg.GetPkgProblemResolver(self._pcache._depcache) + fixer = apt_pkg.ProblemResolver(self._pcache._depcache) fixer.Clear(self._pkg) fixer.Protect(self._pkg) fixer.Resolve(True) diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 41a38588..96426a32 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -4,10 +4,10 @@ import apt_pkg import os -def get_file(fetcher, uri, destFile): +def get_file(fetcher, uri, destfile): # get the file - af = apt_pkg.GetPkgAcqFile(fetcher, uri=uri, descr="sample descr", - destFile=destFile) + af = apt_pkg.AcquireFile(fetcher, uri=uri, descr="sample descr", + destfile=destfile) res = fetcher.Run() if res != fetcher.ResultContinue: return False @@ -19,21 +19,21 @@ apt_pkg.init() #apt_pkg.Config.Set("Debug::pkgPackageManager","1"); #apt_pkg.Config.Set("Debug::pkgDPkgProgressReporting","1"); -cache = apt_pkg.GetCache() -depcache = apt_pkg.GetDepCache(cache) +cache = apt_pkg.Cache() +depcache = apt_pkg.DepCache(cache) -recs = apt_pkg.GetPkgRecords(cache) -list = apt_pkg.GetPkgSourceList() +recs = apt_pkg.PackageRecords(cache) +list = apt_pkg.SourceList() list.ReadMainList() # show the amount fetch needed for a dist-upgrade depcache.Upgrade(True) progress = apt.progress.TextFetchProgress() -fetcher = apt_pkg.GetAcquire(progress) -pm = apt_pkg.GetPackageManager(depcache) +fetcher = apt_pkg.Acquire(progress) +pm = apt_pkg.PackageManager(depcache) pm.GetArchives(fetcher, list, recs) print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded) -actiongroup = apt_pkg.GetPkgActionGroup(depcache) +actiongroup = apt_pkg.ActionGroup(depcache) for pkg in cache.Packages: depcache.MarkKeep(pkg) @@ -48,9 +48,9 @@ pkg = cache["3ddesktop"] depcache.MarkInstall(pkg) progress = apt.progress.TextFetchProgress() -fetcher = apt_pkg.GetAcquire(progress) -#fetcher = apt_pkg.GetAcquire() -pm = apt_pkg.GetPackageManager(depcache) +fetcher = apt_pkg.Acquire(progress) +#fetcher = apt_pkg.Acquire() +pm = apt_pkg.PackageManager(depcache) print pm print fetcher diff --git a/doc/examples/action.py b/doc/examples/action.py index 8ee86eb7..512945df 100644 --- a/doc/examples/action.py +++ b/doc/examples/action.py @@ -10,7 +10,7 @@ from progress import TextFetchProgress apt_pkg.init() progress = OpTextProgress() -cache = apt_pkg.GetCache(progress) +cache = apt_pkg.Cache(progress) print "Available packages: %s " % cache.PackageCount print "Fetching" @@ -25,7 +25,7 @@ print "example package iter: %s" % iter # get depcache print "\n\n depcache" -depcache = apt_pkg.GetDepCache(cache, progress) +depcache = apt_pkg.DepCache(cache, progress) depcache.ReadPinFile() print "got a depcache: %s " % depcache print "Marked for install: %s " % depcache.InstCount diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index b5ac88a2..656f1361 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -21,11 +21,11 @@ def get_source_pkg(pkg, records, depcache): # main apt_pkg.init() -cache = apt_pkg.GetCache() -depcache = apt_pkg.GetDepCache(cache) +cache = apt_pkg.Cache() +depcache = apt_pkg.DepCache(cache) depcache.Init() -records = apt_pkg.GetPkgRecords(cache) -srcrecords = apt_pkg.GetPkgSrcRecords() +records = apt_pkg.PackageRecords(cache) +srcrecords = apt_pkg.SourceRecords() # base package that we use for build-depends calculation if len(sys.argv) < 2: diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py index 408bd720..78f2a8af 100644 --- a/doc/examples/cdrom.py +++ b/doc/examples/cdrom.py @@ -10,7 +10,7 @@ from progress import TextCdromProgress # init apt_pkg.init() -cdrom = apt_pkg.GetCdrom() +cdrom = apt_pkg.Cdrom() print cdrom progress = TextCdromProgress() diff --git a/doc/examples/checkstate.py b/doc/examples/checkstate.py index 3368d500..41040b6c 100755 --- a/doc/examples/checkstate.py +++ b/doc/examples/checkstate.py @@ -8,7 +8,7 @@ import apt_pkg apt_pkg.init() -cache = apt_pkg.GetCache() +cache = apt_pkg.Cache() packages = cache.Packages uninstalled, updated, upgradable = {}, {}, {} diff --git a/doc/examples/config.py b/doc/examples/config.py index 9d4e51fc..0dff4cac 100755 --- a/doc/examples/config.py +++ b/doc/examples/config.py @@ -21,7 +21,7 @@ import posixpath # configuration object apt_pkg.Config which is used interally by apt-pkg # routines to control unusual situations. I recommend using the sytem global # whenever possible.. -Cnf = apt_pkg.newConfiguration() +Cnf = apt_pkg.Configuration() print "Command line is", sys.argv diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py index 8da1ad0a..fe3d161b 100755 --- a/doc/examples/configisc.py +++ b/doc/examples/configisc.py @@ -17,7 +17,7 @@ if len(ConfigFile) != 1: print "Must have exactly 1 file name" sys.exit(0) -Cnf = apt_pkg.newConfiguration() +Cnf = apt_pkg.Configuration() apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0]) # Print the configuration space diff --git a/doc/examples/deb_inspect.py b/doc/examples/deb_inspect.py index cc0d04be..54c52b7b 100755 --- a/doc/examples/deb_inspect.py +++ b/doc/examples/deb_inspect.py @@ -25,7 +25,7 @@ if __name__ == "__main__": print "Now extracting the control file:" control = apt_inst.debExtractControl(open(file)) - sections = apt_pkg.ParseSection(control) + sections = apt_pkg.TagSection(control) print "Maintainer is: " print sections["Maintainer"] diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py index de038fe8..858e45a4 100644 --- a/doc/examples/depcache.py +++ b/doc/examples/depcache.py @@ -9,7 +9,7 @@ from progress import TextProgress apt_pkg.init() progress = TextProgress() -cache = apt_pkg.GetCache(progress) +cache = apt_pkg.Cache(progress) print "Available packages: %s " % cache.PackageCount iter = cache["base-config"] @@ -17,7 +17,7 @@ print "example package iter: %s" % iter # get depcache print "\n\n depcache" -depcache = apt_pkg.GetDepCache(cache) +depcache = apt_pkg.DepCache(cache) depcache.ReadPinFile() # init is needed after the creation/pin file reading depcache.Init(progress) diff --git a/doc/examples/desc.py b/doc/examples/desc.py index 2febf348..d50aa0ce 100644 --- a/doc/examples/desc.py +++ b/doc/examples/desc.py @@ -6,8 +6,8 @@ apt_pkg.init() apt_pkg.Config.Set("APT::Acquire::Translation", "de") -cache = apt_pkg.GetCache() -depcache = apt_pkg.GetDepCache(cache) +cache = apt_pkg.Cache() +depcache = apt_pkg.DepCache(cache) pkg = cache["gcc"] cand = depcache.GetCandidateVer(pkg) @@ -18,7 +18,7 @@ print desc print desc.FileList (f, index) = desc.FileList.pop(0) -records = apt_pkg.GetPkgRecords(cache) +records = apt_pkg.PackageRecords(cache) records.Lookup((f, index)) desc = records.LongDesc print len(desc) diff --git a/doc/examples/indexfile.py b/doc/examples/indexfile.py index 2f1f27f8..cc5070aa 100644 --- a/doc/examples/indexfile.py +++ b/doc/examples/indexfile.py @@ -4,11 +4,11 @@ import apt_pkg apt_pkg.init() -sources = apt_pkg.GetPkgSourceList() +sources = apt_pkg.SourceList() sources.ReadMainList() -cache = apt_pkg.GetCache() -depcache = apt_pkg.GetDepCache(cache) +cache = apt_pkg.Cache() +depcache = apt_pkg.DepCache(cache) pkg = cache["libimlib2"] cand = depcache.GetCandidateVer(pkg) for (f, i) in cand.FileList: diff --git a/doc/examples/metaindex.py b/doc/examples/metaindex.py index 816a3fd7..bbb4ac47 100644 --- a/doc/examples/metaindex.py +++ b/doc/examples/metaindex.py @@ -4,7 +4,7 @@ import apt_pkg apt_pkg.init() -sources = apt_pkg.GetPkgSourceList() +sources = apt_pkg.SourceList() sources.ReadMainList() diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py index 3b678e83..c64a4b54 100755 --- a/doc/examples/print_uris.py +++ b/doc/examples/print_uris.py @@ -13,7 +13,7 @@ upgradable = filter(lambda p: p.isUpgradable, cache) for pkg in upgradable: pkg._lookupRecord(True) - path = apt_pkg.ParseSection(pkg._records.Record)["Filename"] + path = apt_pkg.TagSection(pkg._records.Record)["Filename"] cand = pkg._depcache.GetCandidateVer(pkg._pkg) for (packagefile, i) in cand.FileList: indexfile = cache._list.FindIndex(packagefile) diff --git a/doc/examples/recommends.py b/doc/examples/recommends.py index f0b3b1be..0ecd5882 100755 --- a/doc/examples/recommends.py +++ b/doc/examples/recommends.py @@ -3,7 +3,7 @@ import apt_pkg apt_pkg.init() -cache = apt_pkg.GetCache() +cache = apt_pkg.Cache() class Wanted: diff --git a/doc/examples/sources.py b/doc/examples/sources.py index 49652982..bc08ad69 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -4,10 +4,10 @@ import apt_pkg apt_pkg.init() -#cache = apt_pkg.GetCache() -#sources = apt_pkg.GetPkgSrcRecords(cache) +#cache = apt_pkg.Cache() +#sources = apt_pkg.SourceRecords(cache) -sources = apt_pkg.GetPkgSrcRecords() +sources = apt_pkg.SourceRecords() sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, \ diff --git a/doc/examples/tagfile.py b/doc/examples/tagfile.py index 4faf08ac..770e40de 100755 --- a/doc/examples/tagfile.py +++ b/doc/examples/tagfile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import apt_pkg -Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/status", "r")) +Parse = apt_pkg.TagFile(open("/var/lib/dpkg/status", "r")) while Parse.Step() == 1: print Parse.Section.get("Package") diff --git a/doc/source/examples/cache-packages.py b/doc/source/examples/cache-packages.py index 1abe7cf2..0af96f7d 100644 --- a/doc/source/examples/cache-packages.py +++ b/doc/source/examples/cache-packages.py @@ -8,7 +8,7 @@ def main(): """Main.""" apt_pkg.InitConfig() apt_pkg.InitSystem() - cache = apt_pkg.GetCache() + cache = apt_pkg.Cache() print "Essential packages:" for pkg in cache.Packages: if pkg.Essential: diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py index f25975d3..a7c22c97 100644 --- a/doc/source/examples/cache-pkgfile.py +++ b/doc/source/examples/cache-pkgfile.py @@ -5,7 +5,7 @@ import apt_pkg def main(): """Example for PackageFile()""" apt_pkg.init() - cache = apt_pkg.GetCache() + cache = apt_pkg.Cache() for pkgfile in cache.FileList: print 'Package-File:', pkgfile.FileName print 'Index-Type:', pkgfile.IndexType # 'Debian Package Index' diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py index 3ca16e45..dd5eeb8a 100644 --- a/doc/source/examples/missing-deps.py +++ b/doc/source/examples/missing-deps.py @@ -35,7 +35,7 @@ def main(): apt_pkg.InitConfig() apt_pkg.InitSystem() - cache = apt_pkg.GetCache() + cache = apt_pkg.Cache() for pkg in sorted(cache.Packages, key=lambda pkg: pkg.Name): # pkg is from a list of packages, sorted by name. diff --git a/tests/cache.py b/tests/cache.py index 87a544e8..f0bf6761 100644 --- a/tests/cache.py +++ b/tests/cache.py @@ -9,8 +9,8 @@ import sys def main(): apt_pkg.init() - cache = apt_pkg.GetCache() - depcache = apt_pkg.GetDepCache(cache) + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) depcache.Init() i=0 all=cache.PackageCount diff --git a/tests/depcache.py b/tests/depcache.py index 19aba680..0d59648e 100644 --- a/tests/depcache.py +++ b/tests/depcache.py @@ -9,8 +9,8 @@ import sys def main(): apt_pkg.init() - cache = apt_pkg.GetCache() - depcache = apt_pkg.GetDepCache(cache) + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) depcache.Init() i=0 all=cache.PackageCount diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py index c3f6eff3..c6e5ff80 100644 --- a/tests/getcache_mem_corruption.py +++ b/tests/getcache_mem_corruption.py @@ -13,12 +13,12 @@ class TestGetCache(unittest.TestCase): def testWrongInvocation(self): # wrongly invoke GetCache() rather than GetDepCache() - apt_cache = apt_pkg.GetCache() - self.assertRaises(ValueError, apt_pkg.GetCache, apt_cache) + apt_cache = apt_pkg.Cache() + self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) def testProperInvocation(self): - apt_cache = apt_pkg.GetCache(apt.progress.OpTextProgress()) - apt_depcache = apt_pkg.GetDepCache(apt_cache) + apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress()) + apt_depcache = apt_pkg.DepCache(apt_cache) if __name__ == "__main__": unittest.main() diff --git a/tests/memleak.py b/tests/memleak.py index 659091fc..5299f35f 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -29,10 +29,10 @@ for i in range(100): # 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() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) + records = apt_pkg.PackageRecords(cache) + list = apt_pkg.SourceList() list.ReadMainList() dict = {} for pkg in cache.Packages: diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py index a21d8d9d..0d6d0611 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/pkgproblemresolver.py @@ -9,8 +9,8 @@ import sys def main(): apt_pkg.init() - cache = apt_pkg.GetCache() - depcache = apt_pkg.GetDepCache(cache) + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) depcache.Init() i=0 all=cache.PackageCount @@ -25,7 +25,7 @@ def main(): if ver is not None: depcache.MarkInstall(pkg) if depcache.BrokenCount > 0: - fixer = apt_pkg.GetPkgProblemResolver(depcache) + fixer = apt_pkg.ProblemResolver(depcache) fixer.Clear(pkg) fixer.Protect(pkg) # we first try to resolve the problem diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py index 5866847d..2fe6ad20 100644 --- a/tests/pkgrecords.py +++ b/tests/pkgrecords.py @@ -10,14 +10,14 @@ import sys def main(): apt_pkg.init() - cache = apt_pkg.GetCache() - depcache = apt_pkg.GetDepCache(cache) + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) depcache.Init() i=0 print "Running PkgRecords test on all packages:" for pkg in cache.Packages: i += 1 - records = apt_pkg.GetPkgRecords(cache) + records = apt_pkg.PackageRecords(cache) if len(pkg.VersionList) == 0: #print "no available version, cruft" continue diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py index 77670540..2ea9dd3a 100644 --- a/tests/pkgsrcrecords.py +++ b/tests/pkgsrcrecords.py @@ -10,12 +10,12 @@ import sys def main(): apt_pkg.init() - cache = apt_pkg.GetCache() + cache = apt_pkg.Cache() i=0 print "Running PkgSrcRecords test on all packages:" for x in cache.Packages: i += 1 - src = apt_pkg.GetPkgSrcRecords() + src = apt_pkg.SourceRecords() if src.Lookup(x.Name): #print src.Package pass -- cgit v1.2.3 From cbd822c9dfe8cf18d828bd558290f15775b4d837 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 19:40:47 +0200 Subject: tests: First work on the new testsuite. The module tests.test_all will run all available tests. Each test placed herein must be using unittest and provide at least 1 test case. It must be prefixed with test_. --- tests/__init__.py | 1 + tests/apt-test.py | 26 ----- tests/cache.py | 51 --------- tests/data/sources.list | 6 -- tests/data/sources.list.testDistribution | 13 --- tests/depcache.py | 54 ---------- tests/getcache_mem_corruption.py | 24 ----- tests/hashsum_test.data | 1 - tests/hashsum_test_with_zero.data | Bin 7 -> 0 bytes tests/lock.py | 47 --------- tests/memleak.py | 46 -------- tests/old/__init__.py | 13 +++ tests/old/apt-test.py | 26 +++++ tests/old/cache.py | 51 +++++++++ tests/old/data/sources.list | 6 ++ tests/old/data/sources.list.testDistribution | 13 +++ tests/old/depcache.py | 54 ++++++++++ tests/old/getcache_mem_corruption.py | 24 +++++ tests/old/hashsum_test.data | 1 + tests/old/hashsum_test_with_zero.data | Bin 0 -> 7 bytes tests/old/lock.py | 47 +++++++++ tests/old/memleak.py | 46 ++++++++ tests/old/pkgproblemresolver.py | 70 +++++++++++++ tests/old/pkgrecords.py | 40 +++++++ tests/old/pkgsrcrecords.py | 29 +++++ tests/old/refcount.py | 54 ++++++++++ tests/old/test-data-ports/sources.list | 59 +++++++++++ tests/old/test_aptsources.py | 151 +++++++++++++++++++++++++++ tests/old/test_aptsources_ports.py | 41 ++++++++ tests/old/test_debextract.py | 18 ++++ tests/old/test_extract_archive.py | 10 ++ tests/old/test_hashsums.py | 67 ++++++++++++ tests/pkgproblemresolver.py | 70 ------------- tests/pkgrecords.py | 40 ------- tests/pkgsrcrecords.py | 29 ----- tests/refcount.py | 54 ---------- tests/test-data-ports/sources.list | 59 ----------- tests/test_all.py | 17 +++ tests/test_aptsources.py | 151 --------------------------- tests/test_aptsources_ports.py | 41 -------- tests/test_debextract.py | 18 ---- tests/test_extract_archive.py | 10 -- tests/test_hashes.py | 93 +++++++++++++++++ tests/test_hashsums.py | 67 ------------ 44 files changed, 931 insertions(+), 807 deletions(-) create mode 100644 tests/__init__.py delete mode 100644 tests/apt-test.py delete mode 100644 tests/cache.py delete mode 100644 tests/data/sources.list delete mode 100644 tests/data/sources.list.testDistribution delete mode 100644 tests/depcache.py delete mode 100644 tests/getcache_mem_corruption.py delete mode 100644 tests/hashsum_test.data delete mode 100644 tests/hashsum_test_with_zero.data delete mode 100644 tests/lock.py delete mode 100755 tests/memleak.py create mode 100644 tests/old/__init__.py create mode 100644 tests/old/apt-test.py create mode 100644 tests/old/cache.py create mode 100644 tests/old/data/sources.list create mode 100644 tests/old/data/sources.list.testDistribution create mode 100644 tests/old/depcache.py create mode 100644 tests/old/getcache_mem_corruption.py create mode 100644 tests/old/hashsum_test.data create mode 100644 tests/old/hashsum_test_with_zero.data create mode 100644 tests/old/lock.py create mode 100755 tests/old/memleak.py create mode 100644 tests/old/pkgproblemresolver.py create mode 100644 tests/old/pkgrecords.py create mode 100644 tests/old/pkgsrcrecords.py create mode 100755 tests/old/refcount.py create mode 100644 tests/old/test-data-ports/sources.list create mode 100644 tests/old/test_aptsources.py create mode 100644 tests/old/test_aptsources_ports.py create mode 100755 tests/old/test_debextract.py create mode 100644 tests/old/test_extract_archive.py create mode 100644 tests/old/test_hashsums.py delete mode 100644 tests/pkgproblemresolver.py delete mode 100644 tests/pkgrecords.py delete mode 100644 tests/pkgsrcrecords.py delete mode 100755 tests/refcount.py delete mode 100644 tests/test-data-ports/sources.list create mode 100644 tests/test_all.py delete mode 100644 tests/test_aptsources.py delete mode 100644 tests/test_aptsources_ports.py delete mode 100755 tests/test_debextract.py delete mode 100644 tests/test_extract_archive.py create mode 100644 tests/test_hashes.py delete mode 100644 tests/test_hashsums.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/apt-test.py b/tests/apt-test.py deleted file mode 100644 index fac2ff43..00000000 --- a/tests/apt-test.py +++ /dev/null @@ -1,26 +0,0 @@ -import warnings -warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) -import apt - - -if __name__ == "__main__": - progress = apt.progress.OpTextProgress() - cache = apt.Cache(progress) - print cache - for pkg in cache: - if pkg.isUpgradable: - pkg.markInstall() - for pkg in cache.getChanges(): - #print pkg.Name() - pass - print "Broken: %s " % cache._depcache.BrokenCount - print "InstCount: %s " % cache._depcache.InstCount - - # get a new cache - cache = apt.Cache(progress) - for name in cache.keys(): - import random - if random.randint(0, 1) == 1: - cache[name].markDelete() - print "Broken: %s " % cache._depcache.BrokenCount - print "DelCount: %s " % cache._depcache.DelCount diff --git a/tests/cache.py b/tests/cache.py deleted file mode 100644 index f0bf6761..00000000 --- a/tests/cache.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# -# Test for the pkgCache code -# - -import apt_pkg -import sys - - -def main(): - apt_pkg.init() - cache = apt_pkg.Cache() - depcache = apt_pkg.DepCache(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)), - - -if __name__ == "__main__": - main() - sys.exit(0) diff --git a/tests/data/sources.list b/tests/data/sources.list deleted file mode 100644 index 5481d4f0..00000000 --- a/tests/data/sources.list +++ /dev/null @@ -1,6 +0,0 @@ -# comment 1 -deb http://de.archive.ubuntu.com/ubuntu/ edgy main -# comment 2 -deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted -# comment 3 -deb http://de.archive.ubuntu.com/ubuntu/ edgy universe \ No newline at end of file diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution deleted file mode 100644 index 0f40e85a..00000000 --- a/tests/data/sources.list.testDistribution +++ /dev/null @@ -1,13 +0,0 @@ -deb http://de.archive.ubuntu.com/ubuntu/ hardy main -deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy universe -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse -deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main -deb http://archive.ubuntu.com/ubuntu/ intrepid main -deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main -deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file diff --git a/tests/depcache.py b/tests/depcache.py deleted file mode 100644 index 0d59648e..00000000 --- a/tests/depcache.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Test for the DepCache code -# - -import apt_pkg -import sys - - -def main(): - apt_pkg.init() - cache = apt_pkg.Cache() - depcache = apt_pkg.DepCache(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 is not 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 "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) diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py deleted file mode 100644 index c6e5ff80..00000000 --- a/tests/getcache_mem_corruption.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -import apt -import apt_pkg -import re - -import unittest - -class TestGetCache(unittest.TestCase): - - def setUp(self): - apt_pkg.InitConfig() - apt_pkg.InitSystem() - - def testWrongInvocation(self): - # wrongly invoke GetCache() rather than GetDepCache() - apt_cache = apt_pkg.Cache() - self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) - - def testProperInvocation(self): - apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress()) - apt_depcache = apt_pkg.DepCache(apt_cache) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/hashsum_test.data b/tests/hashsum_test.data deleted file mode 100644 index 19102815..00000000 --- a/tests/hashsum_test.data +++ /dev/null @@ -1 +0,0 @@ -foo \ No newline at end of file diff --git a/tests/hashsum_test_with_zero.data b/tests/hashsum_test_with_zero.data deleted file mode 100644 index 2ec9a6df..00000000 Binary files a/tests/hashsum_test_with_zero.data and /dev/null differ diff --git a/tests/lock.py b/tests/lock.py deleted file mode 100644 index d45b3964..00000000 --- a/tests/lock.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Test for the pkgCache code -# - -import apt_pkg -import sys -import os - - -if __name__ == "__main__": - lock = "/tmp/test.lck" - - apt_pkg.init() - - # system-lock - apt_pkg.PkgSystemLock() - - pid = os.fork() - if pid == 0: - try: - apt_pkg.PkgSystemLock() - except SystemError, s: - print "Can't get lock: (error text:\n%s)" % s - sys.exit(0) - - apt_pkg.PkgSystemUnLock() - - # low-level lock - fd = apt_pkg.GetLock(lock, True) - print "Lockfile fd: %s" % fd - - # try to get lock without error flag - pid = os.fork() - if pid == 0: - # child - fd = apt_pkg.GetLock(lock, False) - print "Lockfile fd (child): %s" % fd - sys.exit(0) - - # try to get lock with error flag - pid = os.fork() - if pid == 0: - # child - fd = apt_pkg.GetLock(lock, True) - print "Lockfile fd (child): %s" % fd - sys.exit(0) diff --git a/tests/memleak.py b/tests/memleak.py deleted file mode 100755 index 5299f35f..00000000 --- a/tests/memleak.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python - -import apt -import apt_pkg -import time -import gc -import sys - - -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() - -# memleak -#for i in range(100): -# 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.Cache() - depcache = apt_pkg.DepCache(cache) - records = apt_pkg.PackageRecords(cache) - list = apt_pkg.SourceList() - 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/old/__init__.py b/tests/old/__init__.py new file mode 100644 index 00000000..afd0f074 --- /dev/null +++ b/tests/old/__init__.py @@ -0,0 +1,13 @@ +import os +import unittest + + + +if __name__ == '__main__': + os.chdir(os.path.dirname(__file__)) + print os.getcwd() + + for path in os.listdir('.'): + if path.endswith('.py'): + exec 'from %s import *' % path[:-3] + unittest.main() diff --git a/tests/old/apt-test.py b/tests/old/apt-test.py new file mode 100644 index 00000000..fac2ff43 --- /dev/null +++ b/tests/old/apt-test.py @@ -0,0 +1,26 @@ +import warnings +warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) +import apt + + +if __name__ == "__main__": + progress = apt.progress.OpTextProgress() + cache = apt.Cache(progress) + print cache + for pkg in cache: + if pkg.isUpgradable: + pkg.markInstall() + for pkg in cache.getChanges(): + #print pkg.Name() + pass + print "Broken: %s " % cache._depcache.BrokenCount + print "InstCount: %s " % cache._depcache.InstCount + + # get a new cache + cache = apt.Cache(progress) + for name in cache.keys(): + import random + if random.randint(0, 1) == 1: + cache[name].markDelete() + print "Broken: %s " % cache._depcache.BrokenCount + print "DelCount: %s " % cache._depcache.DelCount diff --git a/tests/old/cache.py b/tests/old/cache.py new file mode 100644 index 00000000..f0bf6761 --- /dev/null +++ b/tests/old/cache.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# +# Test for the pkgCache code +# + +import apt_pkg +import sys + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(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)), + + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/tests/old/data/sources.list b/tests/old/data/sources.list new file mode 100644 index 00000000..5481d4f0 --- /dev/null +++ b/tests/old/data/sources.list @@ -0,0 +1,6 @@ +# comment 1 +deb http://de.archive.ubuntu.com/ubuntu/ edgy main +# comment 2 +deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted +# comment 3 +deb http://de.archive.ubuntu.com/ubuntu/ edgy universe \ No newline at end of file diff --git a/tests/old/data/sources.list.testDistribution b/tests/old/data/sources.list.testDistribution new file mode 100644 index 00000000..0f40e85a --- /dev/null +++ b/tests/old/data/sources.list.testDistribution @@ -0,0 +1,13 @@ +deb http://de.archive.ubuntu.com/ubuntu/ hardy main +deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy universe +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse +deb http://ftp.debian.org/debian sid main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://archive.ubuntu.com/ubuntu/ intrepid main +deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file diff --git a/tests/old/depcache.py b/tests/old/depcache.py new file mode 100644 index 00000000..0d59648e --- /dev/null +++ b/tests/old/depcache.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python2.4 +# +# Test for the DepCache code +# + +import apt_pkg +import sys + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(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 is not 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 "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) diff --git a/tests/old/getcache_mem_corruption.py b/tests/old/getcache_mem_corruption.py new file mode 100644 index 00000000..c6e5ff80 --- /dev/null +++ b/tests/old/getcache_mem_corruption.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +import apt +import apt_pkg +import re + +import unittest + +class TestGetCache(unittest.TestCase): + + def setUp(self): + apt_pkg.InitConfig() + apt_pkg.InitSystem() + + def testWrongInvocation(self): + # wrongly invoke GetCache() rather than GetDepCache() + apt_cache = apt_pkg.Cache() + self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) + + def testProperInvocation(self): + apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress()) + apt_depcache = apt_pkg.DepCache(apt_cache) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/old/hashsum_test.data b/tests/old/hashsum_test.data new file mode 100644 index 00000000..19102815 --- /dev/null +++ b/tests/old/hashsum_test.data @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/tests/old/hashsum_test_with_zero.data b/tests/old/hashsum_test_with_zero.data new file mode 100644 index 00000000..2ec9a6df Binary files /dev/null and b/tests/old/hashsum_test_with_zero.data differ diff --git a/tests/old/lock.py b/tests/old/lock.py new file mode 100644 index 00000000..d45b3964 --- /dev/null +++ b/tests/old/lock.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python2.4 +# +# Test for the pkgCache code +# + +import apt_pkg +import sys +import os + + +if __name__ == "__main__": + lock = "/tmp/test.lck" + + apt_pkg.init() + + # system-lock + apt_pkg.PkgSystemLock() + + pid = os.fork() + if pid == 0: + try: + apt_pkg.PkgSystemLock() + except SystemError, s: + print "Can't get lock: (error text:\n%s)" % s + sys.exit(0) + + apt_pkg.PkgSystemUnLock() + + # low-level lock + fd = apt_pkg.GetLock(lock, True) + print "Lockfile fd: %s" % fd + + # try to get lock without error flag + pid = os.fork() + if pid == 0: + # child + fd = apt_pkg.GetLock(lock, False) + print "Lockfile fd (child): %s" % fd + sys.exit(0) + + # try to get lock with error flag + pid = os.fork() + if pid == 0: + # child + fd = apt_pkg.GetLock(lock, True) + print "Lockfile fd (child): %s" % fd + sys.exit(0) diff --git a/tests/old/memleak.py b/tests/old/memleak.py new file mode 100755 index 00000000..5299f35f --- /dev/null +++ b/tests/old/memleak.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import apt +import apt_pkg +import time +import gc +import sys + + +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() + +# memleak +#for i in range(100): +# 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.Cache() + depcache = apt_pkg.DepCache(cache) + records = apt_pkg.PackageRecords(cache) + list = apt_pkg.SourceList() + 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/old/pkgproblemresolver.py b/tests/old/pkgproblemresolver.py new file mode 100644 index 00000000..0d6d0611 --- /dev/null +++ b/tests/old/pkgproblemresolver.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python2.4 +# +# Test for the DepCache code +# + +import apt_pkg +import sys + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(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 is not None: + depcache.MarkInstall(pkg) + if depcache.BrokenCount > 0: + fixer = apt_pkg.ProblemResolver(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 "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) diff --git a/tests/old/pkgrecords.py b/tests/old/pkgrecords.py new file mode 100644 index 00000000..2fe6ad20 --- /dev/null +++ b/tests/old/pkgrecords.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python2.4 +# +# Test for the PkgSrcRecords code +# it segfaults for python-apt < 0.5.37 +# + +import apt_pkg +import sys + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) + depcache.Init() + i=0 + print "Running PkgRecords test on all packages:" + for pkg in cache.Packages: + i += 1 + records = apt_pkg.PackageRecords(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) diff --git a/tests/old/pkgsrcrecords.py b/tests/old/pkgsrcrecords.py new file mode 100644 index 00000000..2ea9dd3a --- /dev/null +++ b/tests/old/pkgsrcrecords.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python2.4 +# +# Test for the PkgSrcRecords code +# it segfaults for python-apt < 0.5.37 +# + +import apt_pkg +import sys + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + i=0 + print "Running PkgSrcRecords test on all packages:" + for x in cache.Packages: + i += 1 + src = apt_pkg.SourceRecords() + 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) diff --git a/tests/old/refcount.py b/tests/old/refcount.py new file mode 100755 index 00000000..a29744ae --- /dev/null +++ b/tests/old/refcount.py @@ -0,0 +1,54 @@ +#!/usr/bin/python-dbg + +from pprint import pprint, pformat +import apt +import sys +import gc +import difflib + +# get initial cache +print sys.gettotalrefcount() +progress= apt.progress.OpTextProgress() +c = apt.Cache(progress) +print "refcount after first cache instance: ", sys.gettotalrefcount() + +# test open() +c.open(progress) +print "refcount after cache open: ", sys.gettotalrefcount() +#pprint(sys.getobjects(10)) + +c.open(apt.progress.OpProgress()) +print "refcount after seconf cache open: ", sys.gettotalrefcount() +#pprint(sys.getobjects(10)) + +# FIXME: find a way to get a efficient diff +#before = gc.get_objects() +#c.open(apt.progress.OpProgress()) +#after = gc.get_objects() + + +# test update() +print "refcount before cache.update(): ", sys.gettotalrefcount() +c.update() +gc.collect() +print "refcount after cache.update(): ", sys.gettotalrefcount() +c.update() +gc.collect() +print "refcount after second cache.update(): ", sys.gettotalrefcount() +#pprint(sys.getobjects(20)) + + +# test install() +c.open(apt.progress.OpProgress()) +gc.collect() +print "refcount before cache['hello'].markInstall(): ", sys.gettotalrefcount() +c["hello"].markInstall() +c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) +gc.collect() +print "refcount after: ", sys.gettotalrefcount() +c.open(apt.progress.OpProgress()) +c["hello"].markDelete() +c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) +gc.collect() +print "refcount after: ", sys.gettotalrefcount() +pprint(sys.getobjects(10)) diff --git a/tests/old/test-data-ports/sources.list b/tests/old/test-data-ports/sources.list new file mode 100644 index 00000000..a6b2f6ed --- /dev/null +++ b/tests/old/test-data-ports/sources.list @@ -0,0 +1,59 @@ +# +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted + +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy main restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## universe WILL NOT receive any review or updates from the Ubuntu security +## team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe +deb-src http://archive.ubuntu.com/ubuntu hardy universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe +deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy multiverse +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse + +## Uncomment the following two lines to add software from the 'backports' +## repository. +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse +# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse + +## Uncomment the following two lines to add software from Canonical's +## 'partner' repository. This software is not part of Ubuntu, but is +## offered by Canonical and the respective vendors as a service to Ubuntu +## users. +# deb http://archive.canonical.com/ubuntu hardy partner +# deb-src http://archive.canonical.com/ubuntu hardy partner + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/old/test_aptsources.py b/tests/old/test_aptsources.py new file mode 100644 index 00000000..3761f3ff --- /dev/null +++ b/tests/old/test_aptsources.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python + +import unittest +import os +import copy +import sys + +sys.path.insert(0, "../") +import apt_pkg +import aptsources +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSources(unittest.TestCase): + + def __init__(self, methodName): + unittest.TestCase.__init__(self, methodName) + apt_pkg.init() + apt_pkg.Config.Set("Dir::Etc", os.getcwd()) + apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") + + def testIsMirror(self): + yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://de.archive.ubuntu.com") + no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://ftp.debian.org") + self.assertTrue(yes) + self.assertFalse(no) + + def testSourcesListReading(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") + sources = aptsources.sourceslist.SourcesList() + self.assertEqual(len(sources.list), 6) + # test load + sources.list = [] + sources.load("data/sources.list") + self.assertEqual(len(sources.list), 6) + + def testSourcesListAdding(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") + sources = aptsources.sourceslist.SourcesList() + # test to add something that is already there (main) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["main"]) + self.assertTrue(sources.list == before.list) + # test to add something that is already there (restricted) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["restricted"]) + self.assertTrue(sources.list == before.list) + # test to add something new: multiverse + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["multiverse"]) + found = False + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy" and + "multiverse" in entry.comps): + found = True + self.assertTrue(found) + # test to add something new: multiverse *and* + # something that is already there + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["universe", "something"]) + found_universe = 0 + found_something = 0 + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy"): + for c in entry.comps: + if c == "universe": + found_universe += 1 + if c == "something": + found_something += 1 + #print "\n".join([s.str() for s in sources]) + self.assertEqual(found_something, 1) + self.assertEqual(found_universe, 1) + + def testMatcher(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" + "Distribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if not s.template: + self.fail("source entry '%s' has no matcher" % s) + + def testDistribution(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" + "Distribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if s.template: + dist_templates.add(s.template.name) + #print dist_templates + for d in ("hardy", "hardy-security", "hardy-updates", "intrepid", + "hardy-backports"): + self.assertTrue(d in dist_templates) + # test enable + comp = "restricted" + distro.enable_component(comp) + found = {} + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + "edgy" in entry.dist): + for c in entry.comps: + if c == comp: + if not entry.dist in found: + found[entry.dist] = 0 + found[entry.dist] += 1 + #print "".join([s.str() for s in sources]) + for key in found: + self.assertEqual(found[key], 1) + + # add a not-already available component + comp = "multiverse" + distro.enable_component(comp) + found = {} + for entry in sources: + if (entry.type == "deb" and + entry.template and + entry.template.name == "edgy"): + for c in entry.comps: + if c == comp: + if not entry.dist in found.has_key: + found[entry.dist] = 0 + found[entry.dist] += 1 + #print "".join([s.str() for s in sources]) + for key in found: + self.assertEqual(found[key], 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/old/test_aptsources_ports.py b/tests/old/test_aptsources_ports.py new file mode 100644 index 00000000..09d6e9d9 --- /dev/null +++ b/tests/old/test_aptsources_ports.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +import unittest + +import os +import copy +import sys + +sys.path.insert(0, "../") +import apt_pkg +import aptsources +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSources(unittest.TestCase): + + def __init__(self, methodName): + unittest.TestCase.__init__(self, methodName) + apt_pkg.init() + apt_pkg.Config.Set("APT::Architecture", "powerpc") + apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports")) + apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") + + def testMatcher(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", + "8.04") + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if not s.line.strip() or s.line.startswith("#"): + continue + if not s.template: + self.fail("source entry '%s' has no matcher" % s) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/old/test_debextract.py b/tests/old/test_debextract.py new file mode 100755 index 00000000..4ba498ae --- /dev/null +++ b/tests/old/test_debextract.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +import sys + +import apt_inst + + +def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): + print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( + What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) + + +def main(): + member = "data.tar.lzma" + if len(sys.argv) > 2: + member = sys.argv[2] + apt_inst.debExtract(open(sys.argv[1]), Callback, member) + +main() diff --git a/tests/old/test_extract_archive.py b/tests/old/test_extract_archive.py new file mode 100644 index 00000000..ce202b06 --- /dev/null +++ b/tests/old/test_extract_archive.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import apt +import apt_inst +import os +import sys + +print os.getcwd() +apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/") +print os.getcwd() diff --git a/tests/old/test_hashsums.py b/tests/old/test_hashsums.py new file mode 100644 index 00000000..0cf6beb7 --- /dev/null +++ b/tests/old/test_hashsums.py @@ -0,0 +1,67 @@ +#!/usr/bin/python + +import unittest +import apt_pkg + + +class testHashes(unittest.TestCase): + " test the hashsum functions against strings and files " + + def testMD5(self): + # simple + s = "foo" + s_md5 = "acbd18db4cc2f85cedef654fccc4a4d8" + res = apt_pkg.md5sum(s) + self.assert_(res == s_md5) + # file + res = apt_pkg.md5sum(open("hashsum_test.data")) + self.assert_(res == s_md5) + # with zero (\0) in the string + s = "foo\0bar" + s_md5 = "f6f5f8cd0cb63668898ba29025ae824e" + res = apt_pkg.md5sum(s) + self.assert_(res == s_md5) + # file + res = apt_pkg.md5sum(open("hashsum_test_with_zero.data")) + self.assert_(res == s_md5) + + def testSHA1(self): + # simple + s = "foo" + s_hash = "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" + res = apt_pkg.sha1sum(s) + self.assert_(res == s_hash) + # file + res = apt_pkg.sha1sum(open("hashsum_test.data")) + self.assert_(res == s_hash) + # with zero (\0) in the string + s = "foo\0bar" + s_hash = "e2c300a39311a2dfcaff799528415cb74c19317f" + res = apt_pkg.sha1sum(s) + self.assert_(res == s_hash) + # file + res = apt_pkg.sha1sum(open("hashsum_test_with_zero.data")) + self.assert_(res == s_hash) + + def testSHA256(self): + # simple + s = "foo" + s_hash = \ + "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" + res = apt_pkg.sha256sum(s) + self.assert_(res == s_hash) + # file + res = apt_pkg.sha256sum(open("hashsum_test.data")) + self.assert_(res == s_hash) + # with zero (\0) in the string + s = "foo\0bar" + s_hash = \ + "d6b681bfce7155d44721afb79c296ef4f0fa80a9dd6b43c5cf74dd0f64c85512" + res = apt_pkg.sha256sum(s) + self.assert_(res == s_hash) + # file + res = apt_pkg.sha256sum(open("hashsum_test_with_zero.data")) + self.assert_(res == s_hash) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py deleted file mode 100644 index 0d6d0611..00000000 --- a/tests/pkgproblemresolver.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Test for the DepCache code -# - -import apt_pkg -import sys - - -def main(): - apt_pkg.init() - cache = apt_pkg.Cache() - depcache = apt_pkg.DepCache(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 is not None: - depcache.MarkInstall(pkg) - if depcache.BrokenCount > 0: - fixer = apt_pkg.ProblemResolver(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 "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) diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py deleted file mode 100644 index 2fe6ad20..00000000 --- a/tests/pkgrecords.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Test for the PkgSrcRecords code -# it segfaults for python-apt < 0.5.37 -# - -import apt_pkg -import sys - - -def main(): - apt_pkg.init() - cache = apt_pkg.Cache() - depcache = apt_pkg.DepCache(cache) - depcache.Init() - i=0 - print "Running PkgRecords test on all packages:" - for pkg in cache.Packages: - i += 1 - records = apt_pkg.PackageRecords(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) diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py deleted file mode 100644 index 2ea9dd3a..00000000 --- a/tests/pkgsrcrecords.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Test for the PkgSrcRecords code -# it segfaults for python-apt < 0.5.37 -# - -import apt_pkg -import sys - - -def main(): - apt_pkg.init() - cache = apt_pkg.Cache() - i=0 - print "Running PkgSrcRecords test on all packages:" - for x in cache.Packages: - i += 1 - src = apt_pkg.SourceRecords() - 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) diff --git a/tests/refcount.py b/tests/refcount.py deleted file mode 100755 index a29744ae..00000000 --- a/tests/refcount.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python-dbg - -from pprint import pprint, pformat -import apt -import sys -import gc -import difflib - -# get initial cache -print sys.gettotalrefcount() -progress= apt.progress.OpTextProgress() -c = apt.Cache(progress) -print "refcount after first cache instance: ", sys.gettotalrefcount() - -# test open() -c.open(progress) -print "refcount after cache open: ", sys.gettotalrefcount() -#pprint(sys.getobjects(10)) - -c.open(apt.progress.OpProgress()) -print "refcount after seconf cache open: ", sys.gettotalrefcount() -#pprint(sys.getobjects(10)) - -# FIXME: find a way to get a efficient diff -#before = gc.get_objects() -#c.open(apt.progress.OpProgress()) -#after = gc.get_objects() - - -# test update() -print "refcount before cache.update(): ", sys.gettotalrefcount() -c.update() -gc.collect() -print "refcount after cache.update(): ", sys.gettotalrefcount() -c.update() -gc.collect() -print "refcount after second cache.update(): ", sys.gettotalrefcount() -#pprint(sys.getobjects(20)) - - -# test install() -c.open(apt.progress.OpProgress()) -gc.collect() -print "refcount before cache['hello'].markInstall(): ", sys.gettotalrefcount() -c["hello"].markInstall() -c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) -gc.collect() -print "refcount after: ", sys.gettotalrefcount() -c.open(apt.progress.OpProgress()) -c["hello"].markDelete() -c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) -gc.collect() -print "refcount after: ", sys.gettotalrefcount() -pprint(sys.getobjects(10)) diff --git a/tests/test-data-ports/sources.list b/tests/test-data-ports/sources.list deleted file mode 100644 index a6b2f6ed..00000000 --- a/tests/test-data-ports/sources.list +++ /dev/null @@ -1,59 +0,0 @@ -# -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted - -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## universe WILL NOT receive any review or updates from the Ubuntu security -## team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe -deb-src http://archive.ubuntu.com/ubuntu hardy universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe -deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy multiverse -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse - -## Uncomment the following two lines to add software from the 'backports' -## repository. -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse - -## Uncomment the following two lines to add software from Canonical's -## 'partner' repository. This software is not part of Ubuntu, but is -## offered by Canonical and the respective vendors as a service to Ubuntu -## users. -# deb http://archive.canonical.com/ubuntu hardy partner -# deb-src http://archive.canonical.com/ubuntu hardy partner - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/test_all.py b/tests/test_all.py new file mode 100644 index 00000000..ea74e09b --- /dev/null +++ b/tests/test_all.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# Copyright (C) 2009 Julian Andres Klode +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Run all available unit tests.""" +import os +import unittest + +if __name__ == '__main__': + os.chdir(os.path.dirname(__file__)) + for path in os.listdir('.'): + if path.endswith('.py') and os.path.isfile(path): + exec('from %s import *' % path[:-3]) + + unittest.main() diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py deleted file mode 100644 index 3761f3ff..00000000 --- a/tests/test_aptsources.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python - -import unittest -import os -import copy -import sys - -sys.path.insert(0, "../") -import apt_pkg -import aptsources -import aptsources.sourceslist -import aptsources.distro - - -class TestAptSources(unittest.TestCase): - - def __init__(self, methodName): - unittest.TestCase.__init__(self, methodName) - apt_pkg.init() - apt_pkg.Config.Set("Dir::Etc", os.getcwd()) - apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") - - def testIsMirror(self): - yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://de.archive.ubuntu.com") - no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://ftp.debian.org") - self.assertTrue(yes) - self.assertFalse(no) - - def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - self.assertEqual(len(sources.list), 6) - # test load - sources.list = [] - sources.load("data/sources.list") - self.assertEqual(len(sources.list), 6) - - def testSourcesListAdding(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - # test to add something that is already there (main) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["main"]) - self.assertTrue(sources.list == before.list) - # test to add something that is already there (restricted) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["restricted"]) - self.assertTrue(sources.list == before.list) - # test to add something new: multiverse - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["multiverse"]) - found = False - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy" and - "multiverse" in entry.comps): - found = True - self.assertTrue(found) - # test to add something new: multiverse *and* - # something that is already there - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["universe", "something"]) - found_universe = 0 - found_something = 0 - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): - for c in entry.comps: - if c == "universe": - found_universe += 1 - if c == "something": - found_something += 1 - #print "\n".join([s.str() for s in sources]) - self.assertEqual(found_something, 1) - self.assertEqual(found_universe, 1) - - def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if not s.template: - self.fail("source entry '%s' has no matcher" % s) - - def testDistribution(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if s.template: - dist_templates.add(s.template.name) - #print dist_templates - for d in ("hardy", "hardy-security", "hardy-updates", "intrepid", - "hardy-backports"): - self.assertTrue(d in dist_templates) - # test enable - comp = "restricted" - distro.enable_component(comp) - found = {} - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - "edgy" in entry.dist): - for c in entry.comps: - if c == comp: - if not entry.dist in found: - found[entry.dist] = 0 - found[entry.dist] += 1 - #print "".join([s.str() for s in sources]) - for key in found: - self.assertEqual(found[key], 1) - - # add a not-already available component - comp = "multiverse" - distro.enable_component(comp) - found = {} - for entry in sources: - if (entry.type == "deb" and - entry.template and - entry.template.name == "edgy"): - for c in entry.comps: - if c == comp: - if not entry.dist in found.has_key: - found[entry.dist] = 0 - found[entry.dist] += 1 - #print "".join([s.str() for s in sources]) - for key in found: - self.assertEqual(found[key], 1) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py deleted file mode 100644 index 09d6e9d9..00000000 --- a/tests/test_aptsources_ports.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -import unittest - -import os -import copy -import sys - -sys.path.insert(0, "../") -import apt_pkg -import aptsources -import aptsources.sourceslist -import aptsources.distro - - -class TestAptSources(unittest.TestCase): - - def __init__(self, methodName): - unittest.TestCase.__init__(self, methodName) - apt_pkg.init() - apt_pkg.Config.Set("APT::Architecture", "powerpc") - apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports")) - apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") - - def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", - "8.04") - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if not s.line.strip() or s.line.startswith("#"): - continue - if not s.template: - self.fail("source entry '%s' has no matcher" % s) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_debextract.py b/tests/test_debextract.py deleted file mode 100755 index 4ba498ae..00000000 --- a/tests/test_debextract.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python -import sys - -import apt_inst - - -def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): - print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( - What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) - - -def main(): - member = "data.tar.lzma" - if len(sys.argv) > 2: - member = sys.argv[2] - apt_inst.debExtract(open(sys.argv[1]), Callback, member) - -main() diff --git a/tests/test_extract_archive.py b/tests/test_extract_archive.py deleted file mode 100644 index ce202b06..00000000 --- a/tests/test_extract_archive.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python - -import apt -import apt_inst -import os -import sys - -print os.getcwd() -apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/") -print os.getcwd() diff --git a/tests/test_hashes.py b/tests/test_hashes.py new file mode 100644 index 00000000..24e25f9c --- /dev/null +++ b/tests/test_hashes.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Julian Andres Klode +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Unit tests for verifying the correctness of hashsums in apt_pkg. + +Unit tests to verify the correctness of Hashes, HashString and the various +functions like md5sum.""" +import unittest +import hashlib + +import apt_pkg + + +class TestHashes(unittest.TestCase): + """Test apt_pkg.Hashes() and the various apt_pkg.*sum() functions.""" + + def setUp(self): + """Prepare the tests, create reference values...""" + self.file = open(apt_pkg.__file__, "rb") + self.value = self.file.read() + self.hashes = apt_pkg.Hashes(self.value) + self.file.seek(0) + self.fhashes = apt_pkg.Hashes(self.file) + # Reference values. + self.md5 = hashlib.md5(self.value).hexdigest() + self.sha1 = hashlib.sha1(self.value).hexdigest() + self.sha256 = hashlib.sha256(self.value).hexdigest() + self.file.seek(0) + + def tearDown(self): + """Cleanup, Close the file object used for the tests.""" + self.file.close() + + def test_md5sum(self): + """Test apt_pkg.md5sum()""" + self.assertEqual(apt_pkg.md5sum(self.value), self.md5) + self.assertEqual(apt_pkg.md5sum(self.file), self.md5) + + def test_sha1sum(self): + """Test apt_pkg.sha1sum()""" + self.assertEqual(apt_pkg.sha1sum(self.value), self.sha1) + self.assertEqual(apt_pkg.sha1sum(self.file), self.sha1) + + def test_sha256sum(self): + """Test apt_pkg.sha256sum()""" + self.assertEqual(apt_pkg.sha256sum(self.value), self.sha256) + self.assertEqual(apt_pkg.sha256sum(self.file), self.sha256) + + def test_bytes(self): + """Test apt_pkg.Hashes(bytes)""" + self.assertEqual(self.hashes.md5, self.md5) + self.assertEqual(self.hashes.sha1, self.sha1) + self.assertEqual(self.hashes.sha256, self.sha256) + + def test_file(self): + """Test apt_pkg.Hashes(file).""" + self.assertEqual(self.hashes.md5, self.fhashes.md5) + self.assertEqual(self.hashes.sha1, self.fhashes.sha1) + self.assertEqual(self.hashes.sha256, self.fhashes.sha256) + + +class TestHashString(unittest.TestCase): + """Test apt_pkg.HashString().""" + + def setUp(self): + """Prepare the test by reading the file.""" + self.hashes = apt_pkg.Hashes(open(apt_pkg.__file__)) + self.md5 = apt_pkg.HashString("MD5Sum", self.hashes.md5) + self.sha1 = apt_pkg.HashString("SHA1", self.hashes.sha1) + self.sha256 = apt_pkg.HashString("SHA256", self.hashes.sha256) + + def test_md5(self): + """Test apt_pkg.HashString().md5""" + self.assertEqual("MD5Sum:%s" % self.hashes.md5, str(self.md5)) + self.assertTrue(self.md5.verify_file(apt_pkg.__file__)) + + def test_sha1(self): + """Test apt_pkg.HashString().sha1""" + self.assertEqual("SHA1:%s" % self.hashes.sha1, str(self.sha1)) + self.assertTrue(self.sha1.verify_file(apt_pkg.__file__)) + + def test_sha256(self): + """Test apt_pkg.HashString().sha256""" + self.assertEqual("SHA256:%s" % self.hashes.sha256, str(self.sha256)) + self.assertTrue(self.sha256.verify_file(apt_pkg.__file__)) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_hashsums.py b/tests/test_hashsums.py deleted file mode 100644 index 0cf6beb7..00000000 --- a/tests/test_hashsums.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/python - -import unittest -import apt_pkg - - -class testHashes(unittest.TestCase): - " test the hashsum functions against strings and files " - - def testMD5(self): - # simple - s = "foo" - s_md5 = "acbd18db4cc2f85cedef654fccc4a4d8" - res = apt_pkg.md5sum(s) - self.assert_(res == s_md5) - # file - res = apt_pkg.md5sum(open("hashsum_test.data")) - self.assert_(res == s_md5) - # with zero (\0) in the string - s = "foo\0bar" - s_md5 = "f6f5f8cd0cb63668898ba29025ae824e" - res = apt_pkg.md5sum(s) - self.assert_(res == s_md5) - # file - res = apt_pkg.md5sum(open("hashsum_test_with_zero.data")) - self.assert_(res == s_md5) - - def testSHA1(self): - # simple - s = "foo" - s_hash = "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" - res = apt_pkg.sha1sum(s) - self.assert_(res == s_hash) - # file - res = apt_pkg.sha1sum(open("hashsum_test.data")) - self.assert_(res == s_hash) - # with zero (\0) in the string - s = "foo\0bar" - s_hash = "e2c300a39311a2dfcaff799528415cb74c19317f" - res = apt_pkg.sha1sum(s) - self.assert_(res == s_hash) - # file - res = apt_pkg.sha1sum(open("hashsum_test_with_zero.data")) - self.assert_(res == s_hash) - - def testSHA256(self): - # simple - s = "foo" - s_hash = \ - "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" - res = apt_pkg.sha256sum(s) - self.assert_(res == s_hash) - # file - res = apt_pkg.sha256sum(open("hashsum_test.data")) - self.assert_(res == s_hash) - # with zero (\0) in the string - s = "foo\0bar" - s_hash = \ - "d6b681bfce7155d44721afb79c296ef4f0fa80a9dd6b43c5cf74dd0f64c85512" - res = apt_pkg.sha256sum(s) - self.assert_(res == s_hash) - # file - res = apt_pkg.sha256sum(open("hashsum_test_with_zero.data")) - self.assert_(res == s_hash) - -if __name__ == "__main__": - unittest.main() -- cgit v1.2.3 From a98a389095bce8b95fc8e70e27ade082beb77d6d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 20:01:32 +0200 Subject: tests/test_hashes.py: Add some more tests, especially about unicode. --- tests/test_hashes.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/test_hashes.py b/tests/test_hashes.py index 24e25f9c..520c4925 100644 --- a/tests/test_hashes.py +++ b/tests/test_hashes.py @@ -11,6 +11,7 @@ Unit tests to verify the correctness of Hashes, HashString and the various functions like md5sum.""" import unittest import hashlib +import sys import apt_pkg @@ -62,6 +63,19 @@ class TestHashes(unittest.TestCase): self.assertEqual(self.hashes.sha1, self.fhashes.sha1) self.assertEqual(self.hashes.sha256, self.fhashes.sha256) + def test_unicode(self): + """Test apt_pkg.Hashes(unicode).""" + if sys.version_info[0] == 3: + self.assertRaises(TypeError, apt_pkg.Hashes, "D") + self.assertRaises(TypeError, apt_pkg.md5sum, "D") + self.assertRaises(TypeError, apt_pkg.sha1sum, "D") + self.assertRaises(TypeError, apt_pkg.sha256sum, "D") + else: + self.assertRaises(TypeError, apt_pkg.Hashes, unicode()) + self.assertRaises(TypeError, apt_pkg.md5sum, unicode()) + self.assertRaises(TypeError, apt_pkg.sha1sum, unicode()) + self.assertRaises(TypeError, apt_pkg.sha256sum, unicode()) + class TestHashString(unittest.TestCase): """Test apt_pkg.HashString().""" @@ -88,6 +102,12 @@ class TestHashString(unittest.TestCase): self.assertEqual("SHA256:%s" % self.hashes.sha256, str(self.sha256)) self.assertTrue(self.sha256.verify_file(apt_pkg.__file__)) + def test_wrong(self): + """Test wrong invocation of HashString.""" + self.assertRaises(TypeError, apt_pkg.HashString, 0) + if sys.version_info[0] == 3: + self.assertRaises(TypeError, apt_pkg.HashString, bytes()) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3 From 3b23463156a4e119c520e0e45df09d04b815bebe Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 20:25:17 +0200 Subject: tests/test_cache_invocation.py: Move here from old. --- tests/old/getcache_mem_corruption.py | 24 ------------------------ tests/test_cache_invocation.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 24 deletions(-) delete mode 100644 tests/old/getcache_mem_corruption.py create mode 100644 tests/test_cache_invocation.py (limited to 'tests') diff --git a/tests/old/getcache_mem_corruption.py b/tests/old/getcache_mem_corruption.py deleted file mode 100644 index c6e5ff80..00000000 --- a/tests/old/getcache_mem_corruption.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -import apt -import apt_pkg -import re - -import unittest - -class TestGetCache(unittest.TestCase): - - def setUp(self): - apt_pkg.InitConfig() - apt_pkg.InitSystem() - - def testWrongInvocation(self): - # wrongly invoke GetCache() rather than GetDepCache() - apt_cache = apt_pkg.Cache() - self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) - - def testProperInvocation(self): - apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress()) - apt_depcache = apt_pkg.DepCache(apt_cache) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py new file mode 100644 index 00000000..9d34891d --- /dev/null +++ b/tests/test_cache_invocation.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +import apt_pkg + +import unittest + +class TestCache(unittest.TestCase): + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + + def test_wrong_invocation(self): + """wrongly invoke GetCache() rather than GetDepCache().""" + apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + if apt_pkg._COMPAT_0_7: + self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) + self.assertRaises(ValueError, apt_pkg.Cache, + apt_pkg.AcquireProgress()) + self.assertRaises(ValueError, apt_pkg.Cache, 0) + else: + self.assertRaises(TypeError, apt_pkg.Cache, apt_cache) + self.assertRaises(TypeError, apt_pkg.Cache, + apt_pkg.AcquireProgress()) + self.assertRaises(TypeError, apt_pkg.Cache, 0) + + def test_proper_invocation(self): + """Invoke it the right way.""" + apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + apt_depcache = apt_pkg.DepCache(apt_cache) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3 From c88f6ea1f3d2cca1ff7f1a22f51318ea3f28c01f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 20:53:45 +0200 Subject: tests: Import more tests from tests/old. --- tests/__init__.py | 2 +- tests/data/aptsources/sources.list | 6 + .../data/aptsources/sources.list.testDistribution | 13 ++ tests/data/aptsources_ports/sources.list | 59 ++++++++ tests/old/data/sources.list | 6 - tests/old/data/sources.list.testDistribution | 13 -- tests/old/test-data-ports/sources.list | 59 -------- tests/old/test_aptsources.py | 151 -------------------- tests/old/test_aptsources_ports.py | 41 ------ tests/test_aptsources.py | 155 +++++++++++++++++++++ tests/test_aptsources_ports.py | 39 ++++++ tests/test_cache_invocation.py | 8 +- 12 files changed, 278 insertions(+), 274 deletions(-) create mode 100644 tests/data/aptsources/sources.list create mode 100644 tests/data/aptsources/sources.list.testDistribution create mode 100644 tests/data/aptsources_ports/sources.list delete mode 100644 tests/old/data/sources.list delete mode 100644 tests/old/data/sources.list.testDistribution delete mode 100644 tests/old/test-data-ports/sources.list delete mode 100644 tests/old/test_aptsources.py delete mode 100644 tests/old/test_aptsources_ports.py create mode 100644 tests/test_aptsources.py create mode 100644 tests/test_aptsources_ports.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py index 8b137891..792d6005 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ - +# diff --git a/tests/data/aptsources/sources.list b/tests/data/aptsources/sources.list new file mode 100644 index 00000000..5481d4f0 --- /dev/null +++ b/tests/data/aptsources/sources.list @@ -0,0 +1,6 @@ +# comment 1 +deb http://de.archive.ubuntu.com/ubuntu/ edgy main +# comment 2 +deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted +# comment 3 +deb http://de.archive.ubuntu.com/ubuntu/ edgy universe \ No newline at end of file diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution new file mode 100644 index 00000000..4ff0fae6 --- /dev/null +++ b/tests/data/aptsources/sources.list.testDistribution @@ -0,0 +1,13 @@ +deb http://de.archive.ubuntu.com/ubuntu/ hardy main +deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy universe +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse +deb http://ftp.debian.org/debian sid main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://archive.ubuntu.com/ubuntu/ intrepid main +deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main diff --git a/tests/data/aptsources_ports/sources.list b/tests/data/aptsources_ports/sources.list new file mode 100644 index 00000000..a6b2f6ed --- /dev/null +++ b/tests/data/aptsources_ports/sources.list @@ -0,0 +1,59 @@ +# +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted + +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy main restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## universe WILL NOT receive any review or updates from the Ubuntu security +## team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe +deb-src http://archive.ubuntu.com/ubuntu hardy universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe +deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy multiverse +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse + +## Uncomment the following two lines to add software from the 'backports' +## repository. +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse +# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse + +## Uncomment the following two lines to add software from Canonical's +## 'partner' repository. This software is not part of Ubuntu, but is +## offered by Canonical and the respective vendors as a service to Ubuntu +## users. +# deb http://archive.canonical.com/ubuntu hardy partner +# deb-src http://archive.canonical.com/ubuntu hardy partner + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/old/data/sources.list b/tests/old/data/sources.list deleted file mode 100644 index 5481d4f0..00000000 --- a/tests/old/data/sources.list +++ /dev/null @@ -1,6 +0,0 @@ -# comment 1 -deb http://de.archive.ubuntu.com/ubuntu/ edgy main -# comment 2 -deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted -# comment 3 -deb http://de.archive.ubuntu.com/ubuntu/ edgy universe \ No newline at end of file diff --git a/tests/old/data/sources.list.testDistribution b/tests/old/data/sources.list.testDistribution deleted file mode 100644 index 0f40e85a..00000000 --- a/tests/old/data/sources.list.testDistribution +++ /dev/null @@ -1,13 +0,0 @@ -deb http://de.archive.ubuntu.com/ubuntu/ hardy main -deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy universe -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse -deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main -deb http://archive.ubuntu.com/ubuntu/ intrepid main -deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main -deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file diff --git a/tests/old/test-data-ports/sources.list b/tests/old/test-data-ports/sources.list deleted file mode 100644 index a6b2f6ed..00000000 --- a/tests/old/test-data-ports/sources.list +++ /dev/null @@ -1,59 +0,0 @@ -# -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted - -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## universe WILL NOT receive any review or updates from the Ubuntu security -## team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe -deb-src http://archive.ubuntu.com/ubuntu hardy universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe -deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy multiverse -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse - -## Uncomment the following two lines to add software from the 'backports' -## repository. -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse - -## Uncomment the following two lines to add software from Canonical's -## 'partner' repository. This software is not part of Ubuntu, but is -## offered by Canonical and the respective vendors as a service to Ubuntu -## users. -# deb http://archive.canonical.com/ubuntu hardy partner -# deb-src http://archive.canonical.com/ubuntu hardy partner - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/old/test_aptsources.py b/tests/old/test_aptsources.py deleted file mode 100644 index 3761f3ff..00000000 --- a/tests/old/test_aptsources.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python - -import unittest -import os -import copy -import sys - -sys.path.insert(0, "../") -import apt_pkg -import aptsources -import aptsources.sourceslist -import aptsources.distro - - -class TestAptSources(unittest.TestCase): - - def __init__(self, methodName): - unittest.TestCase.__init__(self, methodName) - apt_pkg.init() - apt_pkg.Config.Set("Dir::Etc", os.getcwd()) - apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") - - def testIsMirror(self): - yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://de.archive.ubuntu.com") - no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://ftp.debian.org") - self.assertTrue(yes) - self.assertFalse(no) - - def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - self.assertEqual(len(sources.list), 6) - # test load - sources.list = [] - sources.load("data/sources.list") - self.assertEqual(len(sources.list), 6) - - def testSourcesListAdding(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - # test to add something that is already there (main) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["main"]) - self.assertTrue(sources.list == before.list) - # test to add something that is already there (restricted) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["restricted"]) - self.assertTrue(sources.list == before.list) - # test to add something new: multiverse - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["multiverse"]) - found = False - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy" and - "multiverse" in entry.comps): - found = True - self.assertTrue(found) - # test to add something new: multiverse *and* - # something that is already there - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["universe", "something"]) - found_universe = 0 - found_something = 0 - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): - for c in entry.comps: - if c == "universe": - found_universe += 1 - if c == "something": - found_something += 1 - #print "\n".join([s.str() for s in sources]) - self.assertEqual(found_something, 1) - self.assertEqual(found_universe, 1) - - def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if not s.template: - self.fail("source entry '%s' has no matcher" % s) - - def testDistribution(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if s.template: - dist_templates.add(s.template.name) - #print dist_templates - for d in ("hardy", "hardy-security", "hardy-updates", "intrepid", - "hardy-backports"): - self.assertTrue(d in dist_templates) - # test enable - comp = "restricted" - distro.enable_component(comp) - found = {} - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - "edgy" in entry.dist): - for c in entry.comps: - if c == comp: - if not entry.dist in found: - found[entry.dist] = 0 - found[entry.dist] += 1 - #print "".join([s.str() for s in sources]) - for key in found: - self.assertEqual(found[key], 1) - - # add a not-already available component - comp = "multiverse" - distro.enable_component(comp) - found = {} - for entry in sources: - if (entry.type == "deb" and - entry.template and - entry.template.name == "edgy"): - for c in entry.comps: - if c == comp: - if not entry.dist in found.has_key: - found[entry.dist] = 0 - found[entry.dist] += 1 - #print "".join([s.str() for s in sources]) - for key in found: - self.assertEqual(found[key], 1) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/old/test_aptsources_ports.py b/tests/old/test_aptsources_ports.py deleted file mode 100644 index 09d6e9d9..00000000 --- a/tests/old/test_aptsources_ports.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -import unittest - -import os -import copy -import sys - -sys.path.insert(0, "../") -import apt_pkg -import aptsources -import aptsources.sourceslist -import aptsources.distro - - -class TestAptSources(unittest.TestCase): - - def __init__(self, methodName): - unittest.TestCase.__init__(self, methodName) - apt_pkg.init() - apt_pkg.Config.Set("APT::Architecture", "powerpc") - apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports")) - apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") - - def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", - "8.04") - distro.get_sources(sources) - # test if all suits of the current distro were detected correctly - dist_templates = set() - for s in sources: - if not s.line.strip() or s.line.startswith("#"): - continue - if not s.template: - self.fail("source entry '%s' has no matcher" % s) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py new file mode 100644 index 00000000..e5cd1f5a --- /dev/null +++ b/tests/test_aptsources.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python + +import unittest +import os +import copy + +import apt_pkg +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSources(unittest.TestCase): + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + apt_pkg.config.set("Dir::Etc", os.getcwd()) + apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + + def testIsMirror(self): + """Test mirror detection.""" + yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://de.archive.ubuntu.com") + no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://ftp.debian.org") + self.assertTrue(yes) + self.assertFalse(no) + + def testSourcesListReading(self): + """Test sources.list parsing.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList() + self.assertEqual(len(sources.list), 6) + # test load + sources.list = [] + sources.load("data/aptsources/sources.list") + self.assertEqual(len(sources.list), 6) + + def testSourcesListAdding(self): + """Test additions to sources.list""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList() + # test to add something that is already there (main) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["main"]) + self.assertTrue(sources.list == before.list) + # test to add something that is already there (restricted) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["restricted"]) + self.assertTrue(sources.list == before.list) + # test to add something new: multiverse + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["multiverse"]) + found = False + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy" and + "multiverse" in entry.comps): + found = True + self.assertTrue(found) + # test to add something new: multiverse *and* + # something that is already there + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["universe", "something"]) + found_universe = 0 + found_something = 0 + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy"): + for c in entry.comps: + if c == "universe": + found_universe += 1 + if c == "something": + found_something += 1 + #print "\n".join([s.str() for s in sources]) + self.assertEqual(found_something, 1) + self.assertEqual(found_universe, 1) + + def testMatcher(self): + """Test matcher (detection of what is what in sources.list)""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if not s.template: + self.fail("source entry '%s' has no matcher" % s) + + def testDistribution(self): + """Test distribution detection.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if s.template: + dist_templates.add(s.template.name) + #print dist_templates + for d in ("hardy", "hardy-security", "hardy-updates", "intrepid", + "hardy-backports"): + self.assertTrue(d in dist_templates) + # test enable + comp = "restricted" + distro.enable_component(comp) + found = {} + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + "edgy" in entry.dist): + for c in entry.comps: + if c == comp: + if not entry.dist in found: + found[entry.dist] = 0 + found[entry.dist] += 1 + #print "".join([s.str() for s in sources]) + for key in found: + self.assertEqual(found[key], 1) + + # add a not-already available component + comp = "multiverse" + distro.enable_component(comp) + found = {} + for entry in sources: + if (entry.type == "deb" and + entry.template and + entry.template.name == "edgy"): + for c in entry.comps: + if c == comp: + if not entry.dist in found.has_key: + found[entry.dist] = 0 + found[entry.dist] += 1 + #print "".join([s.str() for s in sources]) + for key in found: + self.assertEqual(found[key], 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py new file mode 100644 index 00000000..5594ec0b --- /dev/null +++ b/tests/test_aptsources_ports.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import os +import unittest + + +import apt_pkg +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSourcesPorts(unittest.TestCase): + """Test aptsources on ports.ubuntu.com.""" + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + apt_pkg.config.set("APT::Architecture", "powerpc") + apt_pkg.config.set("Dir::Etc", + os.path.abspath("data/aptsources_ports")) + apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + + def testMatcher(self): + """Test matcher.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", + "8.04") + distro.get_sources(sources) + # test if all suits of the current distro were detected correctly + dist_templates = set() + for s in sources: + if not s.line.strip() or s.line.startswith("#"): + continue + if not s.template: + self.fail("source entry '%s' has no matcher" % s) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py index 9d34891d..39dae8f4 100644 --- a/tests/test_cache_invocation.py +++ b/tests/test_cache_invocation.py @@ -1,16 +1,18 @@ #!/usr/bin/python +import unittest + import apt_pkg -import unittest class TestCache(unittest.TestCase): + """Test invocation of apt_pkg.Cache()""" def setUp(self): apt_pkg.init_config() apt_pkg.init_system() def test_wrong_invocation(self): - """wrongly invoke GetCache() rather than GetDepCache().""" + """Test wrong invocation of apt_pkg.Cache(apt_pkg.Cache())""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) if apt_pkg._COMPAT_0_7: self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) @@ -24,7 +26,7 @@ class TestCache(unittest.TestCase): self.assertRaises(TypeError, apt_pkg.Cache, 0) def test_proper_invocation(self): - """Invoke it the right way.""" + """Test correct invocation of apt_pkg.DepCache(apt_pkg.Cache()).""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) apt_depcache = apt_pkg.DepCache(apt_cache) -- cgit v1.2.3 From 4ae2f454115f3ab758ef9bf0b1f31e5b04ac934a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 23 Jul 2009 15:09:08 +0200 Subject: tests: Prefix all docstring with the name of the file. --- tests/test_aptsources.py | 11 ++++++----- tests/test_aptsources_ports.py | 2 +- tests/test_cache_invocation.py | 4 ++-- tests/test_hashes.py | 20 ++++++++++---------- 4 files changed, 19 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index e5cd1f5a..0ae05bf3 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -18,7 +18,7 @@ class TestAptSources(unittest.TestCase): apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") def testIsMirror(self): - """Test mirror detection.""" + """aptsources: Test mirror detection.""" yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", "http://de.archive.ubuntu.com") no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", @@ -27,7 +27,7 @@ class TestAptSources(unittest.TestCase): self.assertFalse(no) def testSourcesListReading(self): - """Test sources.list parsing.""" + """aptsources: Test sources.list parsing.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") sources = aptsources.sourceslist.SourcesList() @@ -38,7 +38,7 @@ class TestAptSources(unittest.TestCase): self.assertEqual(len(sources.list), 6) def testSourcesListAdding(self): - """Test additions to sources.list""" + """aptsources: Test additions to sources.list""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") sources = aptsources.sourceslist.SourcesList() @@ -88,7 +88,7 @@ class TestAptSources(unittest.TestCase): self.assertEqual(found_universe, 1) def testMatcher(self): - """Test matcher (detection of what is what in sources.list)""" + """aptsources: Test matcher""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") sources = aptsources.sourceslist.SourcesList() @@ -101,7 +101,7 @@ class TestAptSources(unittest.TestCase): self.fail("source entry '%s' has no matcher" % s) def testDistribution(self): - """Test distribution detection.""" + """aptsources: Test distribution detection.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") sources = aptsources.sourceslist.SourcesList() @@ -152,4 +152,5 @@ class TestAptSources(unittest.TestCase): if __name__ == "__main__": + os.chdir(os.path.dirname(__file__)) unittest.main() diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py index 5594ec0b..f837585b 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -20,7 +20,7 @@ class TestAptSourcesPorts(unittest.TestCase): apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") def testMatcher(self): - """Test matcher.""" + """aptsources_ports: Test matcher.""" apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list") sources = aptsources.sourceslist.SourcesList() distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py index 39dae8f4..ff86b102 100644 --- a/tests/test_cache_invocation.py +++ b/tests/test_cache_invocation.py @@ -12,7 +12,7 @@ class TestCache(unittest.TestCase): apt_pkg.init_system() def test_wrong_invocation(self): - """Test wrong invocation of apt_pkg.Cache(apt_pkg.Cache())""" + """cache_invocation: Test wrong invocation.""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) if apt_pkg._COMPAT_0_7: self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) @@ -26,7 +26,7 @@ class TestCache(unittest.TestCase): self.assertRaises(TypeError, apt_pkg.Cache, 0) def test_proper_invocation(self): - """Test correct invocation of apt_pkg.DepCache(apt_pkg.Cache()).""" + """cache_invocation: Test correct invocation.""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) apt_depcache = apt_pkg.DepCache(apt_cache) diff --git a/tests/test_hashes.py b/tests/test_hashes.py index 520c4925..e0aabe09 100644 --- a/tests/test_hashes.py +++ b/tests/test_hashes.py @@ -37,34 +37,34 @@ class TestHashes(unittest.TestCase): self.file.close() def test_md5sum(self): - """Test apt_pkg.md5sum()""" + """hashes: Test apt_pkg.md5sum()""" self.assertEqual(apt_pkg.md5sum(self.value), self.md5) self.assertEqual(apt_pkg.md5sum(self.file), self.md5) def test_sha1sum(self): - """Test apt_pkg.sha1sum()""" + """hashes: Test apt_pkg.sha1sum()""" self.assertEqual(apt_pkg.sha1sum(self.value), self.sha1) self.assertEqual(apt_pkg.sha1sum(self.file), self.sha1) def test_sha256sum(self): - """Test apt_pkg.sha256sum()""" + """hashes: Test apt_pkg.sha256sum()""" self.assertEqual(apt_pkg.sha256sum(self.value), self.sha256) self.assertEqual(apt_pkg.sha256sum(self.file), self.sha256) def test_bytes(self): - """Test apt_pkg.Hashes(bytes)""" + """hashes: Test apt_pkg.Hashes(bytes)""" self.assertEqual(self.hashes.md5, self.md5) self.assertEqual(self.hashes.sha1, self.sha1) self.assertEqual(self.hashes.sha256, self.sha256) def test_file(self): - """Test apt_pkg.Hashes(file).""" + """hashes: Test apt_pkg.Hashes(file).""" self.assertEqual(self.hashes.md5, self.fhashes.md5) self.assertEqual(self.hashes.sha1, self.fhashes.sha1) self.assertEqual(self.hashes.sha256, self.fhashes.sha256) def test_unicode(self): - """Test apt_pkg.Hashes(unicode).""" + """hashes: Test apt_pkg.Hashes(unicode).""" if sys.version_info[0] == 3: self.assertRaises(TypeError, apt_pkg.Hashes, "D") self.assertRaises(TypeError, apt_pkg.md5sum, "D") @@ -88,22 +88,22 @@ class TestHashString(unittest.TestCase): self.sha256 = apt_pkg.HashString("SHA256", self.hashes.sha256) def test_md5(self): - """Test apt_pkg.HashString().md5""" + """hashes: Test apt_pkg.HashString().md5""" self.assertEqual("MD5Sum:%s" % self.hashes.md5, str(self.md5)) self.assertTrue(self.md5.verify_file(apt_pkg.__file__)) def test_sha1(self): - """Test apt_pkg.HashString().sha1""" + """hashes: Test apt_pkg.HashString().sha1""" self.assertEqual("SHA1:%s" % self.hashes.sha1, str(self.sha1)) self.assertTrue(self.sha1.verify_file(apt_pkg.__file__)) def test_sha256(self): - """Test apt_pkg.HashString().sha256""" + """hashes: Test apt_pkg.HashString().sha256""" self.assertEqual("SHA256:%s" % self.hashes.sha256, str(self.sha256)) self.assertTrue(self.sha256.verify_file(apt_pkg.__file__)) def test_wrong(self): - """Test wrong invocation of HashString.""" + """hashes: Test apt_pkg.HashString(wrong_type).""" self.assertRaises(TypeError, apt_pkg.HashString, 0) if sys.version_info[0] == 3: self.assertRaises(TypeError, apt_pkg.HashString, bytes()) -- cgit v1.2.3 From 68120a33ecb68da02cfb8124244be79ff5a2fad8 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 3 Aug 2009 18:49:19 +0200 Subject: tests/test_cache_invocation.py: Adapt to new progress API. --- tests/test_cache_invocation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py index ff86b102..4245eb50 100644 --- a/tests/test_cache_invocation.py +++ b/tests/test_cache_invocation.py @@ -2,6 +2,7 @@ import unittest import apt_pkg +import apt.progress.base class TestCache(unittest.TestCase): @@ -13,21 +14,21 @@ class TestCache(unittest.TestCase): def test_wrong_invocation(self): """cache_invocation: Test wrong invocation.""" - apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + apt_cache = apt_pkg.Cache(apt.progress.base.OpProgress()) if apt_pkg._COMPAT_0_7: self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) self.assertRaises(ValueError, apt_pkg.Cache, - apt_pkg.AcquireProgress()) + apt.progress.base.AcquireProgress()) self.assertRaises(ValueError, apt_pkg.Cache, 0) else: self.assertRaises(TypeError, apt_pkg.Cache, apt_cache) self.assertRaises(TypeError, apt_pkg.Cache, - apt_pkg.AcquireProgress()) + apt.progress.base.AcquireProgress()) self.assertRaises(TypeError, apt_pkg.Cache, 0) def test_proper_invocation(self): """cache_invocation: Test correct invocation.""" - apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + apt_cache = apt_pkg.Cache(apt.progress.base.OpProgress()) apt_depcache = apt_pkg.DepCache(apt_cache) if __name__ == "__main__": -- cgit v1.2.3 From e71cab3fc74af481bd55ff4fd22285889a637514 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 18 Aug 2009 15:21:29 +0200 Subject: tests/test_cache_invocation.py: Fix for COMPAT_0_7=0. We dropped the special progress base classes some time ago, but still checked here. --- tests/test_cache_invocation.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py index 4245eb50..6f4014de 100644 --- a/tests/test_cache_invocation.py +++ b/tests/test_cache_invocation.py @@ -15,16 +15,11 @@ class TestCache(unittest.TestCase): def test_wrong_invocation(self): """cache_invocation: Test wrong invocation.""" apt_cache = apt_pkg.Cache(apt.progress.base.OpProgress()) - if apt_pkg._COMPAT_0_7: - self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) - self.assertRaises(ValueError, apt_pkg.Cache, - apt.progress.base.AcquireProgress()) - self.assertRaises(ValueError, apt_pkg.Cache, 0) - else: - self.assertRaises(TypeError, apt_pkg.Cache, apt_cache) - self.assertRaises(TypeError, apt_pkg.Cache, - apt.progress.base.AcquireProgress()) - self.assertRaises(TypeError, apt_pkg.Cache, 0) + + self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) + self.assertRaises(ValueError, apt_pkg.Cache, + apt.progress.base.AcquireProgress()) + self.assertRaises(ValueError, apt_pkg.Cache, 0) def test_proper_invocation(self): """cache_invocation: Test correct invocation.""" -- cgit v1.2.3 From dadba850a99f4ae87ac0a7a89b60bae849d76306 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 16:41:39 +0100 Subject: * tests: - Fix aptsources tests to use local data files if available. --- debian/changelog | 2 ++ tests/test_aptsources.py | 12 ++++++++---- tests/test_aptsources_ports.py | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/debian/changelog b/debian/changelog index ad42ddda..57a42c60 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - Implement the iterator protocol in TagFile. * data/templates/Debian.info.in: - Replace the MatchURI with one that really matches something. + * tests: + - Fix aptsources tests to use local data files if available. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 0ae05bf3..0f7f078b 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -16,6 +16,10 @@ class TestAptSources(unittest.TestCase): apt_pkg.init_system() apt_pkg.config.set("Dir::Etc", os.getcwd()) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + if os.path.exists("../build/data/templates"): + self.templates = os.path.abspath("../build/data/templates") + else: + self.templates = "/usr/share/python-apt/templates/" def testIsMirror(self): """aptsources: Test mirror detection.""" @@ -30,7 +34,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test sources.list parsing.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) self.assertEqual(len(sources.list), 6) # test load sources.list = [] @@ -41,7 +45,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test additions to sources.list""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) # test to add something that is already there (main) before = copy.deepcopy(sources) sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", @@ -91,7 +95,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test matcher""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro() distro.get_sources(sources) # test if all suits of the current distro were detected correctly @@ -104,7 +108,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test distribution detection.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro() distro.get_sources(sources) # test if all suits of the current distro were detected correctly diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py index f837585b..991b532a 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -18,11 +18,15 @@ class TestAptSourcesPorts(unittest.TestCase): apt_pkg.config.set("Dir::Etc", os.path.abspath("data/aptsources_ports")) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + if os.path.exists("../build/data/templates"): + self.templates = os.path.abspath("../build/data/templates") + else: + self.templates = "/usr/share/python-apt/templates/" def testMatcher(self): """aptsources_ports: Test matcher.""" apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", "8.04") distro.get_sources(sources) -- cgit v1.2.3 From eb37b3a44fe8e6f15de5211d89fcf63cdf2f6fa6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 17:05:58 +0100 Subject: test_all.py: Use local modules instead of system ones if possible. --- debian/changelog | 1 + tests/test_all.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'tests') diff --git a/debian/changelog b/debian/changelog index e076d029..c63d3a16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - Call lsb_release with -idrc instead of --all. * tests: - Fix aptsources tests to use local data files if available. + - test_all.py: Use local modules instead of system ones if possible. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/tests/test_all.py b/tests/test_all.py index ea74e09b..6900e0ad 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -7,9 +7,24 @@ """Run all available unit tests.""" import os import unittest +import sys if __name__ == '__main__': os.chdir(os.path.dirname(__file__)) + # Find the path to the built apt_pkg and apt_inst extensions + if os.path.exists("../build"): + from distutils.util import get_platform + from distutils.sysconfig import get_python_version + # Set the path to the build directory. + plat_specifier = ".%s-%s" % (get_platform(), get_python_version()) + if sys.version_info[0] >= 3 or sys.version_info[1] >= 6: + library_dir = "../build/lib%s%s" % (plat_specifier, + (sys.pydebug and "-pydebug" or "")) + else: + library_dir = "../build/lib%s%s" % ((sys.pydebug and "_d" or ""), + plat_specifier) + sys.path.insert(0, os.path.abspath(library_dir)) + for path in os.listdir('.'): if path.endswith('.py') and os.path.isfile(path): exec('from %s import *' % path[:-3]) -- cgit v1.2.3 From 809ff1217079cb8e4790a1bc8f1fe187c8ded358 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 19:37:43 +0100 Subject: * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. --- debian/changelog | 2 + po/python-apt.pot | 140 ++++++++++----------- .../data/aptsources/sources.list.testDistribution | 4 +- 3 files changed, 74 insertions(+), 72 deletions(-) (limited to 'tests') diff --git a/debian/changelog b/debian/changelog index 0aab0c2a..cb825163 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ python-apt (0.7.93.4) unstable; urgency=low - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) + * tests/data/aptsources/sources.list.testDistribution: + - change one mirror which is not on the mirror list anymore. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/po/python-apt.pot b/po/python-apt.pot index 36a04eae..b67d7988 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-01-31 17:09+0100\n" +"POT-Creation-Date: 2010-03-03 19:34+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,257 +23,257 @@ msgid "http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:13 +#: ../data/templates/Ubuntu.info.in:12 msgid "Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:31 +#: ../data/templates/Ubuntu.info.in:30 msgid "Cdrom with Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:74 +#: ../data/templates/Ubuntu.info.in:72 msgid "Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:92 +#: ../data/templates/Ubuntu.info.in:90 msgid "Cdrom with Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:135 +#: ../data/templates/Ubuntu.info.in:132 msgid "Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:153 +#: ../data/templates/Ubuntu.info.in:150 msgid "Cdrom with Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:196 +#: ../data/templates/Ubuntu.info.in:192 msgid "Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:214 +#: ../data/templates/Ubuntu.info.in:210 msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:258 +#: ../data/templates/Ubuntu.info.in:253 msgid "Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:276 +#: ../data/templates/Ubuntu.info.in:271 msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:313 +#: ../data/templates/Ubuntu.info.in:308 msgid "Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:331 +#: ../data/templates/Ubuntu.info.in:326 msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:366 +#: ../data/templates/Ubuntu.info.in:361 msgid "Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:384 +#: ../data/templates/Ubuntu.info.in:379 msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:418 +#: ../data/templates/Ubuntu.info.in:413 msgid "Ubuntu 6.10 'Edgy Eft'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:423 +#: ../data/templates/Ubuntu.info.in:418 msgid "Community-maintained" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:429 +#: ../data/templates/Ubuntu.info.in:424 msgid "Restricted software" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:436 +#: ../data/templates/Ubuntu.info.in:431 msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:470 +#: ../data/templates/Ubuntu.info.in:465 msgid "Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:473 +#: ../data/templates/Ubuntu.info.in:468 msgid "Canonical-supported Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:475 +#: ../data/templates/Ubuntu.info.in:470 msgid "Community-maintained (universe)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:476 +#: ../data/templates/Ubuntu.info.in:471 msgid "Community-maintained Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:478 +#: ../data/templates/Ubuntu.info.in:473 msgid "Non-free drivers" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:479 +#: ../data/templates/Ubuntu.info.in:474 msgid "Proprietary drivers for devices" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:481 +#: ../data/templates/Ubuntu.info.in:476 msgid "Restricted software (Multiverse)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:482 +#: ../data/templates/Ubuntu.info.in:477 msgid "Software restricted by copyright or legal issues" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:488 +#: ../data/templates/Ubuntu.info.in:483 msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:500 +#: ../data/templates/Ubuntu.info.in:495 msgid "Important security updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:505 +#: ../data/templates/Ubuntu.info.in:500 msgid "Recommended updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:510 +#: ../data/templates/Ubuntu.info.in:505 msgid "Pre-released updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:515 +#: ../data/templates/Ubuntu.info.in:510 msgid "Unsupported updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:522 +#: ../data/templates/Ubuntu.info.in:517 msgid "Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:536 +#: ../data/templates/Ubuntu.info.in:531 msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:548 +#: ../data/templates/Ubuntu.info.in:543 msgid "Ubuntu 5.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:553 +#: ../data/templates/Ubuntu.info.in:548 msgid "Ubuntu 5.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:558 +#: ../data/templates/Ubuntu.info.in:553 msgid "Ubuntu 5.10 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:565 +#: ../data/templates/Ubuntu.info.in:560 msgid "Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:579 +#: ../data/templates/Ubuntu.info.in:574 msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:582 ../data/templates/Debian.info.in:148 +#: ../data/templates/Ubuntu.info.in:577 ../data/templates/Debian.info.in:149 msgid "Officially supported" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:591 +#: ../data/templates/Ubuntu.info.in:586 msgid "Ubuntu 5.04 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:596 +#: ../data/templates/Ubuntu.info.in:591 msgid "Ubuntu 5.04 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:601 +#: ../data/templates/Ubuntu.info.in:596 msgid "Ubuntu 5.04 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:607 +#: ../data/templates/Ubuntu.info.in:602 msgid "Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:613 +#: ../data/templates/Ubuntu.info.in:608 msgid "Community-maintained (Universe)" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:615 +#: ../data/templates/Ubuntu.info.in:610 msgid "Non-free (Multiverse)" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:621 +#: ../data/templates/Ubuntu.info.in:616 msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:624 +#: ../data/templates/Ubuntu.info.in:619 msgid "No longer officially supported" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:626 +#: ../data/templates/Ubuntu.info.in:621 msgid "Restricted copyright" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:633 +#: ../data/templates/Ubuntu.info.in:628 msgid "Ubuntu 4.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:638 +#: ../data/templates/Ubuntu.info.in:633 msgid "Ubuntu 4.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:643 +#: ../data/templates/Ubuntu.info.in:638 msgid "Ubuntu 4.10 Backports" msgstr "" @@ -324,17 +324,17 @@ msgid "Debian testing" msgstr "" #. Description -#: ../data/templates/Debian.info.in:146 +#: ../data/templates/Debian.info.in:147 msgid "Debian 'Sid' (unstable)" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:150 +#: ../data/templates/Debian.info.in:151 msgid "DFSG-compatible Software with Non-Free Dependencies" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:152 +#: ../data/templates/Debian.info.in:153 msgid "Non-DFSG-compatible Software" msgstr "" @@ -356,39 +356,39 @@ msgstr "" msgid "Custom servers" msgstr "" -#: ../apt/progress/gtk2.py:259 ../apt/progress/gtk2.py:315 +#: ../apt/progress/gtk2.py:260 ../apt/progress/gtk2.py:316 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "" -#: ../apt/progress/gtk2.py:265 ../apt/progress/gtk2.py:321 +#: ../apt/progress/gtk2.py:266 ../apt/progress/gtk2.py:322 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "" #. Setup some child widgets -#: ../apt/progress/gtk2.py:341 +#: ../apt/progress/gtk2.py:342 msgid "Details" msgstr "" -#: ../apt/progress/gtk2.py:429 +#: ../apt/progress/gtk2.py:430 msgid "Starting..." msgstr "" -#: ../apt/progress/gtk2.py:435 +#: ../apt/progress/gtk2.py:436 msgid "Complete" msgstr "" -#: ../apt/package.py:333 +#: ../apt/package.py:342 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:989 ../apt/package.py:1095 +#: ../apt/package.py:999 ../apt/package.py:1105 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:1099 +#: ../apt/package.py:1109 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -397,23 +397,23 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:1105 +#: ../apt/package.py:1115 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." msgstr "" -#: ../apt/debfile.py:70 +#: ../apt/debfile.py:73 #, python-format msgid "List of files for '%s' could not be read" msgstr "" -#: ../apt/debfile.py:138 +#: ../apt/debfile.py:141 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "" -#: ../apt/debfile.py:162 +#: ../apt/debfile.py:165 #, python-format msgid "Conflicts with the installed package '%s'" msgstr "" @@ -437,12 +437,12 @@ msgstr "" msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:473 +#: ../apt/debfile.py:472 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:483 +#: ../apt/debfile.py:482 msgid "An essential package would be removed" msgstr "" @@ -493,6 +493,6 @@ msgstr "" msgid "Please insert a Disc in the drive and press enter" msgstr "" -#: ../apt/cache.py:127 +#: ../apt/cache.py:131 msgid "Building data structures" msgstr "" diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution index 4ff0fae6..79224a34 100644 --- a/tests/data/aptsources/sources.list.testDistribution +++ b/tests/data/aptsources/sources.list.testDistribution @@ -6,8 +6,8 @@ deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy-backports main deb http://archive.ubuntu.com/ubuntu/ intrepid main deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main -- cgit v1.2.3 From ab48075a8c46d8006337754dea80bf8e8930a4b0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 15:01:18 +0100 Subject: * python/apt_pkgmodule.cc: - Treat '>>' and '>', '<<' and '<' as identical in check_dep (LP: #535667). * tests: - test_deps: Add tests for apt_pkg.CheckDep, apt_pkg.check_dep, apt_pkg.parse_depends and apt_pkg.parse_src_depends. --- debian/changelog | 5 ++ python/apt_pkgmodule.cc | 30 ++++++++++++ tests/test_deps.py | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 tests/test_deps.py (limited to 'tests') diff --git a/debian/changelog b/debian/changelog index 090ee043..5c6e6895 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.93.4) unstable; urgency=low * python/acquire-item.cc: - Add AcquireItem.partialsize member. + * python/apt_pkgmodule.cc: + - Treat '>>' and '>', '<<' and '<' as identical in check_dep (LP: #535667). * python/generic.cc: - Map UntranslatedDepType to dep_type_untranslated. * python/tag.cc: @@ -24,6 +26,9 @@ python-apt (0.7.93.4) unstable; urgency=low - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) + * tests: + - test_deps: Add tests for apt_pkg.CheckDep, apt_pkg.check_dep, + apt_pkg.parse_depends and apt_pkg.parse_src_depends. * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. * utils/get_debian_mirrors.py: diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e3da1820..1885a84a 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -91,6 +91,35 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args) char *OpStr; unsigned int Op = 0; + if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) + return 0; + + if (strcmp(OpStr, ">") == 0) OpStr = ">>"; + if (strcmp(OpStr, "<") == 0) OpStr = "<<"; + if (*debListParser::ConvertRelation(OpStr,Op) != 0) + { + PyErr_SetString(PyExc_ValueError,"Bad comparision operation"); + return 0; + } + + if (_system == 0) + { + PyErr_SetString(PyExc_ValueError,"_system not initialized"); + return 0; + } + + return Py_BuildValue("i",_system->VS->CheckDep(A,Op,B)); +// return Py_BuildValue("i",pkgCheckDep(B,A,Op)); +} + +static char *doc_CheckDepOld = "CheckDep(PkgVer,DepOp,DepVer) -> int"; +static PyObject *CheckDepOld(PyObject *Self,PyObject *Args) +{ + char *A; + char *B; + char *OpStr; + unsigned int Op = 0; + if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) return 0; if (*debListParser::ConvertRelation(OpStr,Op) != 0) @@ -473,6 +502,7 @@ static PyMethodDef methods[] = // DEPRECATED #ifdef COMPAT_0_7 + {"CheckDep",CheckDepOld,METH_VARARGS,doc_CheckDepOld}, {"newConfiguration",newConfiguration,METH_VARARGS,doc_newConfiguration}, {"InitConfig",InitConfig,METH_VARARGS,doc_InitConfig}, {"InitSystem",InitSystem,METH_VARARGS,doc_InitSystem}, diff --git a/tests/test_deps.py b/tests/test_deps.py new file mode 100644 index 00000000..674c9485 --- /dev/null +++ b/tests/test_deps.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# +# Copyright (C) 2010 Julian Andres Klode +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Unit tests for verifying the correctness of check_dep, etc in apt_pkg.""" +import unittest + +import apt_pkg + + +class TestDependencies(unittest.TestCase): + + def setUp(self): + apt_pkg.init() + + def testCheckDep(self): + """dependencies: Test apt_pkg.CheckDep() for '<' and '>' + + The CheckDep function should treat '<' as '<=' and '>' as '>=', for + compatibility reasons.""" + if not hasattr(apt_pkg, 'CheckDep'): + return + self.assertFalse(apt_pkg.CheckDep("1", "<", "0")) + self.assertTrue(apt_pkg.CheckDep("1", "<", "1")) + self.assertTrue(apt_pkg.CheckDep("1", "<", "2")) + + self.assertFalse(apt_pkg.CheckDep("0", ">", "1")) + self.assertTrue(apt_pkg.CheckDep("1", ">", "1")) + self.assertTrue(apt_pkg.CheckDep("2", ">", "1")) + + def test_check_dep(self): + "dependencies: Test apt_pkg.check_dep()" + self.assertFalse(apt_pkg.check_dep("1", "<<", "0")) + self.assertFalse(apt_pkg.check_dep("1", "<<", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<<", "2")) + + self.assertFalse(apt_pkg.check_dep("1", "<", "0")) + self.assertFalse(apt_pkg.check_dep("1", "<", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<", "2")) + + self.assertFalse(apt_pkg.check_dep("1", "<=", "0")) + self.assertTrue(apt_pkg.check_dep("1", "<=", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<=", "2")) + + self.assertFalse(apt_pkg.check_dep("0", "=", "1")) + self.assertTrue(apt_pkg.check_dep("1", "=", "1")) + self.assertFalse(apt_pkg.check_dep("2", "=", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">=", "1")) + self.assertTrue(apt_pkg.check_dep("1", ">=", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">=", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">", "1")) + self.assertFalse(apt_pkg.check_dep("1", ">", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">>", "1")) + self.assertFalse(apt_pkg.check_dep("1", ">>", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">>", "1")) + + def test_parse_depends(self): + """dependencies: Test apt_pkg.parse_depends()""" + deps = apt_pkg.parse_depends("p1a (<< 1a) | p1b (>> 1b)") + self.assertTrue(isinstance(deps, list)) + self.assertEqual(len(deps), 1) + self.assertTrue(isinstance(deps[0], list)) + self.assertEqual(len(deps[0]), 2) + self.assertEqual(len(deps[0][0]), 3) + self.assertEqual(len(deps[0][1]), 3) + self.assertEqual(deps[0][0][0], "p1a") + self.assertEqual(deps[0][0][1], "1a") + self.assertEqual(deps[0][0][2], "<") + self.assertEqual(deps[0][1][0], "p1b") + self.assertEqual(deps[0][1][1], "1b") + self.assertEqual(deps[0][1][2], ">") + + # Check that the type of comparison is parsed correctly. + self.assertEqual("<", apt_pkg.parse_depends("p1 (<< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.parse_depends("p1 (< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.parse_depends("p1 (<= 1)")[0][0][2]) + self.assertEqual("=", apt_pkg.parse_depends("p1 (= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.parse_depends("p1 (>= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.parse_depends("p1 (> 1)")[0][0][2]) + self.assertEqual(">", apt_pkg.parse_depends("p1 (>> 1)")[0][0][2]) + + def test_parse_src_depends(self): + """dependencies: Test apt_pkg.parse_src_depends().""" + # Check that architecture exclusion works + # depends_this: Current architecture is included + # depends_this_too: Another architecture is excluded + # depends_other: The current architecture is excluded + # depends_other: Another architecture is requested. + architecture = apt_pkg.config["APT::Architecture"] + depends_this = apt_pkg.parse_src_depends("p [%s]" % architecture) + depends_this_too = apt_pkg.parse_src_depends("p [!not-existing-arch]") + depends_other = apt_pkg.parse_src_depends("p [!%s]" % architecture) + depends_other_too = apt_pkg.parse_src_depends("p [not-existing-arch]") + + self.assertEqual(len(depends_this), len(depends_this_too), 1) + self.assertEqual(len(depends_other), len(depends_other_too), 0) + + def testParseDepends(self): + """dependencies: Test apt_pkg.ParseDepends().""" + if not hasattr(apt_pkg, 'ParseDepends'): + return + # Check that the type of comparison is parsed correctly. + self.assertEqual("<<", apt_pkg.ParseDepends("p1 (<< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.ParseDepends("p1 (< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.ParseDepends("p1 (<= 1)")[0][0][2]) + self.assertEqual("=", apt_pkg.ParseDepends("p1 (= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.ParseDepends("p1 (>= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.ParseDepends("p1 (> 1)")[0][0][2]) + self.assertEqual(">>", apt_pkg.ParseDepends("p1 (>> 1)")[0][0][2]) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3 From 7acdf9b8c3c644bb0cb38c542d6a0ab955c9bb18 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 16:05:24 +0100 Subject: tests/test_all.py: Print the version info on start. --- tests/test_all.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test_all.py b/tests/test_all.py index 6900e0ad..dc603dfd 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -10,6 +10,7 @@ import unittest import sys if __name__ == '__main__': + print("[tests] Running on %s" % sys.version.replace("\n", "")) os.chdir(os.path.dirname(__file__)) # Find the path to the built apt_pkg and apt_inst extensions if os.path.exists("../build"): -- cgit v1.2.3 From 092deeee998dfa2695c586c8105120bd586e8fd1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 14:29:24 +0100 Subject: tests/test_all.py: Write information header to stderr, not stdout. --- debian/changelog | 1 + tests/test_all.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/debian/changelog b/debian/changelog index 6970a7cc..f33f4ed5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Use dh_link instead of ln for python-apt-doc (Closes: #573523). * Pass --link-doc=python-apt to dh_installdocs. * Install examples to python-apt-doc instead of python-apt. + * tests/test_all.py: Write information header to stderr, not stdout. -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/tests/test_all.py b/tests/test_all.py index dc603dfd..d561a9ae 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -10,7 +10,7 @@ import unittest import sys if __name__ == '__main__': - print("[tests] Running on %s" % sys.version.replace("\n", "")) + sys.stderr.write("[tests] Running on %s\n" % sys.version.replace("\n", "")) os.chdir(os.path.dirname(__file__)) # Find the path to the built apt_pkg and apt_inst extensions if os.path.exists("../build"): -- cgit v1.2.3 From 4652428c6c964991ca1384c1a7f7d0e2a7028356 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 19:26:11 +0100 Subject: Revert 0.7.93.3 and just set APT::Architecture to i386 for test_aptsources; fixes FTBFS on powerpc. --- data/templates/Ubuntu.info.in | 15 ++++++++++----- debian/changelog | 7 +++++++ tests/test_aptsources.py | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index a84cbc2b..1ca76927 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -8,7 +8,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 10.04 'Lucid Lynx' Component: main _CompDescription: Officially supported @@ -68,7 +69,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.10 'Karmic Koala' Component: main _CompDescription: Officially supported @@ -128,7 +130,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.04 'Jaunty Jackalope' Component: main _CompDescription: Officially supported @@ -188,7 +191,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.10 'Intrepid Ibex' Component: main _CompDescription: Officially supported @@ -249,7 +253,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.04 'Hardy Heron' Component: main _CompDescription: Officially supported diff --git a/debian/changelog b/debian/changelog index be9888d3..31bdf042 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.94.2) unstable; urgency=low + + * Revert 0.7.93.3 and just set APT::Architecture to i386 for + test_aptsources; fixes FTBFS on powerpc. + + -- Julian Andres Klode Fri, 12 Mar 2010 19:22:57 +0100 + python-apt (0.7.94.1) unstable; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 0f7f078b..767f5244 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -14,6 +14,8 @@ class TestAptSources(unittest.TestCase): def setUp(self): apt_pkg.init_config() apt_pkg.init_system() + if apt_pkg.config["APT::Architecture"] not in ('i386', 'amd64'): + apt_pkg.config.set("APT::Architecture", "i386") apt_pkg.config.set("Dir::Etc", os.getcwd()) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") if os.path.exists("../build/data/templates"): -- cgit v1.2.3