diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-23 18:57:27 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-23 18:57:27 +0100 |
| commit | 36a56f0d7b810858145b1058c72f51eaa76d0d76 (patch) | |
| tree | d85d9291a16cd9726a6d502e2681896171912ccb /tests | |
| parent | 2aa709e41d8896ef897863ea9181c409c4c87a8c (diff) | |
| parent | 73eff261f0c50609b3cee3ff099b1891d4c909f3 (diff) | |
| download | python-apt-36a56f0d7b810858145b1058c72f51eaa76d0d76.tar.gz | |
Updated to the 0.7.9x series (FFe LP: #531518)
[ Julian Andres Klode ]
* python/generic.cc:
- Fix a memory leak when using old attribute names.
* debian/control:
- Change priority to standard, keep -doc and -dev on optional.
[ Michael Vogt ]
* apt/cache.py:
- make cache open silent by default (use apt.progress.base.OpProgress)
* tests/data/aptsources_ports/sources.list:
- fix ports test-data
* debian/control
- build against XS-Python-Versions: 2.6, 3.1
* tests/test_apt_cache.py:
- add simple test for basic cache/dependency iteration
* apt/__init__.py:
- only show deprecation warnings if PYTHON_APT_DEPRECATION_WARNINGS
is set in the environment. While we do want to have the new API its
not feasible to port all apps in the lucid timeframe. Once lucid
is released we turn the warnings on by default again
* Revert 0.7.93.3 and just set APT::Architecture to i386 for
test_aptsources; fixes FTBFS on powerpc.
* Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend
on python2.6; but recommend python2.6.
* 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.
* Build documentation only when needed (when building python-apt-doc).
* Move documentation into python-apt-doc (Closes: #572617)
* Build documentation only once on the default Python version.
* 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:
- Hack the TagFile iterator to not use shared storage (Closes: #572596):
Scan once, duplicate the section data, and scan again.
* apt/package.py:
- Create a string class BaseDependency.__dstr which makes '>' equal to
'>>' and '<' equal to '<<' (compatibility).
- Use the binary package version in Version.fetch_source() if the
source version is not specified (i.e. in the normal case).
- Always return unicode strings in Package.get_changelog (Closes: #572998).
* apt/progress/text.py:
- Drop InstallProgress, it's useless to keep this alias around.
* apt/progress/old.py:
- Let the new method call the old one; e.g. status_update() now calls
self.statusUpdate(). This improves compatibility for sub classes.
* Merge with Ubuntu:
- util/get_ubuntu_mirrors_from_lp.py:
+ rewritten to use +archivemirrors-rss and feedburner
- 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:
- Parse Mirrors.masterlist instead of the HTML web page.
* utils/get_ubuntu_mirrors_from_lp.py:
- Sort the mirror list of each country.
- Use generic MirrorsFile key instead of per-architecture ones in
order to fix FTBFS on !amd64 !i386 (Closes: #571752)
[ Julian Andres Klode ]
* Fix some places where the old API was still used:
- apt/utils.py: Completely ported, previous one was old-API from Ubuntu.
- apt/cache.py: Use the new progress classes instead of the old ones.
- apt/package.py: Various smaller issues fixed, probably caused by merge.
* utils/migrate-0.8.py:
- Improve C++ parsing and add apt.progress.old to the modules, reduces
false positives.
- Ship the list of deprecated things in the apt_pkg and apt_inst modules
inside the script itself, so we don't have to parse the source code
anymore.
* python:
- Handle deprecated attributes and methods in the tp_gettattro slot, this
allows us to easily warn if a deprecated function is used.
* python/tagfile.cc:
- Implement the iterator protocol in TagFile.
* python/cache.cc:
- Implement Cache.__len__() and Cache.__contains__() (Closes: #571443).
* data/templates/Debian.info.in:
- Replace the MatchURI with one that really matches something.
* aptsources/distro.py:
- 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.
* data/templates/*.in: Switch MirrorsFile to relative filenames.
- setup.py: Copy the mirror lists to the build directory
- aptsources/distinfo.py: Support relative filenames for MirrorsFile.
* debian/rules:
- Run tests during build time.
* debian/python-apt.install:
- Install utils/migrate-0.8.py to /usr/share/python-apt/.
[ Michael Vogt ]
* apt/cache.py:
- call install_progress.startUpdate()/finishUpdate() to keep
compatibility with older code
* apt/progress/base.py:
- restore "self.statusfd, self.writefd" type, provide additional
self.status_stream and self.write_stream file like objects
* python/progress.cc:
- try to call compatibility functions first, then new functions
[ Julian Andres Klode ]
* Fix reference counting for old progress classes (Closes: #566370).
* apt/cache.py:
- Fix Cache.update() to not raise errors on successful updates.
* python/progress.cc:
- Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS)
* python/acquire-item.cc:
- Support items without an owner set.
* python/tarfile.cc:
- When extracting, only allocate a new buffer if the old one was too small.
- Do not segfault if TarFile.go() is called without a member name.
- Clone all pkgDirStream::Item's so apt_pkg.TarMember object can be used
outside of the callback function passed to go().
- If only one member is requested, extract just that one.
* Drop the segfault prevention measures from the Acquire code, as they fail
to work. A replacement will be added once destruction callbacks are added
in APT.
* Merge the CppOwnedPyObject C++ class into CppPyObject.
* Remove inline functions from the C++ API, export them instead.
* Localization
- de.po: Update against new template
* python/arfile.cc:
- Handle the case where ararchive_new returns NULL in debfile_new.
* apt/progress/base.py:
- select.error objects do not have an errno attribute (Closes: #568005)
* doc/client-example.cc: Update against the new API.
* Fix typos of separated in multiple files (reported by lintian).
* debian/control:
- Make python-apt-dev depend on ${misc:Depends} and recommend python-dev.
- Set Standards-Version to 3.8.4.
[ Michael Vogt ]
[ Julian Andres Klode ]
* Merge debian-sid and debian-experimental.
* Add a tutorial on how to do things which are possible with apt-get,
like apt-get --print-uris update (cf. #551164).
* Build for Python 2.5, 2.6 and 3.1; 2.6 and 3.1 hit unstable on Jan 16.
- Use DH_PYCENTRAL=nomove for now because include-links seems broken
* Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error
- Return False in Cache.is_virtual_package if the package does not exist.
* Make all class-level constants have uppercase names.
* Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2
build-time dependency.
* aptsources:
- Make all classes subclasses of object.
- distro.py: Support Python 3, decode lsb_release results using utf-8.
* apt/progress/base.py:
- Fix some parsing of dpkg status fd.
* apt/progress/text.py:
- Replace one print statement with a .write() call.
* Rename apt_pkg.PackageIndexFile to apt_pkg.IndexFile.
[ Colin Watson ]
* apt/progress/__init__.py:
- Fix InstallProgress.updateInterface() to cope with read() returning 0
on non-blocking file descriptors (LP: #491027).
* New features:
- Provide a C++ API in the package python-apt-dev (Closes: #334923).
- Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141).
- Add apt_pkg.Policy class (Closes: #382725).
- Add apt_pkg.Hashes class.
- Allow types providing __new__() to be subclassed.
- Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to
mark a package as automatically installed.
- Make AcquireFile a subclass of AcquireItem, thus inheriting attributes.
- New progress handling in apt.progress.base and apt.progress.text. Still
missing Qt4 progress handlers.
- Classes in apt_inst (Closes: #536096)
+ You can now use apt_inst.DebFile.data to access the data.tar.* member
regardless of its compression (LP: #44493)
* Unification of dependency handling:
- apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb
(i.e. < instead of <<) to match the interface of Version.depends_list_str
- apt_pkg.SourceRecords.build_depends matches exactly the interface of
Version.depends_list_str just with different keys (e.g. Build-Depends).
+ Closes: #468123 - there is no need anymore for binding CompType or
CompTypeDeb, because we don't return integer values for CompType
anymore.
* Bugfixes:
- Delete pointers correctly, fixing memory leaks (LP: #370149).
- Drop open() and close() in apt_pkg.Cache as they cause segfaults.
- Raise ValueError in AcquireItem if the Acquire process is shut down
instead of segfaulting.
* Other stuff:
- Merge releases 0.7.10.4 - 0.7.12.1 from unstable.
- Merge Configuration,ConfigurationPtr,ConfigurationSub into one type.
- Simplify the whole build process by using a single setup.py.
- The documentation has been restructured and enhanced with tutorials.
- Only recommend lsb-release instead of depending on it. Default to
Debian unstable if lsb_release is not available.
[ Julian Andres Klode ]
* Rename where needed according to PEP 8 conventions (Closes: #481061)
* Where possible, derive apt.package.Record from collections.Mapping.
* ActionGroups can be used as a context manager for the 'with' statement.
* utils/migrate-0.8.py: Helper to check Python code for deprecated functions,
attributes,etc. Has to be run from the python-apt source tree, but can be
used for all Python code using python-apt.
* debian/control: Only recommend libjs-jquery (Closes: #527543).
[ Stefano Zacchiroli ]
* debian/python-apt.doc-base: register the documentation with the
doc-base system (Closes: #525134)
[ Sebastian Heinlein ]
* apt/package.py: Add Package.get_version() which returns a Version instance
for the given version string or None (Closes: #523998)
* Introduce support for Python 3 (Closes: #523645)
* Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub}
objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection())
* Replace support for file objects with a more generic support for any object
providing a fileno() method and for file descriptors (integers).
* Add support for the Breaks fields
* Only create Package objects when they are requested, do not keep them in
a dict. Saves 10MB for 25,000 packages on my machine.
* apt/package.py: Allow to set the candidate of a package (Closes: #523997)
- Support assignments to the 'candidate' property of Package objects.
- Initial patch by Sebastian Heinlein
[ Michael Vogt ]
* data/templates/Ubuntu.info.in:
- make armel point to ports.ubuntu.com (LP: #531876)
[ Emmet Hikory ]
* data/templates/Ubuntu.info.in:
- refactor to use ports by default for gutsy and newer releases
- Set appropriate exceptions to defaults for warty-lucid
* Drop build dependency on python2.4.
* apt/utils.py:
- add some misc utils like get_release_filename_for_pkg()
[ Michael Vogt ]
* apt/cache.py:
- improved docstring for the cache
- add "enhances" property
* data/templates/Ubuntu.info.in:
- add lucid
* python/cache.cc:
- add UntranslatedDepType attribute to DependencyType
- add DepTypeEnum that returns a value from
{DepDepends, DepPreDepends, ...}
* python/apt_pkgmodule.cc:
- add DepDpkgBreaks, DepEnhances constants
* doc/source/apt_pkg/{cache.rst, index.rst}:
- update documentation as well
* Fix FTBFS with python-debian (>= 0.1.13) on Python 2.4 by not using it to
get a version number in setup.py (Closes: #523473)
* apt/package.py:
- (Package.candidateRecord): Fix missing 'd' in 'record'
- (DeprecatedProperty.__get__): Only warn when used on objects, this
makes it easier to use e.g. pydoc,sphinx,pychecker.
* Merged python-apt consolidation branch by Sebastian
Heinlein (many thanks)
* apt/cache.py:
- new method "isVirtualPackage()"
- new method "getProvidingPackages()"
- new method "getRequiredDownload()"
- new method "additionalRequiredSpace()"
* apt/debfile.py:
- move a lot of the gdebi code into this file, this
provides interfaces for querrying and installing
.deb files and .dsc files
* apt/package.py:
- better description parsing
- new method "installedFiles()"
- new method "getChangelog()"
* apt/gtk/widgets.py:
- new gobject GOpProgress
- new gobject GFetchProgress
- new gobject GInstallProgress
- new gobject GDpkgInstallProgress
- new widget GtkAptProgress
* doc/examples/gui-inst.py:
- updated to use the new widgets
* debian/control:
- add suggests for python-gtk2 and python-vte
* setup.py:
- build html/ help of the apt and aptsources modules
into /usr/share/doc/python-apt/html
* apt/__init__.py:
- remove the future warning
* Non-maintainer upload.
* data/templates/Debian.info.in: Set the BaseURI to security.debian.org for
lenny/updates, etch/updates and sarge/updates. (Closes: #503237)
* data/templates/Debian.info.in:
- add 'lenny' template info (closes: #476364)
* aptsources/distinfo.py:
- fix template matching for arch specific code (LP: #244093)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/__init__.py | 1 | ||||
| -rw-r--r-- | tests/data/aptsources/sources.list (renamed from tests/data/sources.list) | 0 | ||||
| -rw-r--r-- | tests/data/aptsources/sources.list.testDistribution (renamed from tests/data/sources.list.testDistribution) | 6 | ||||
| -rw-r--r-- | tests/data/aptsources_ports/sources.list (renamed from tests/test-data-ports/sources.list) | 16 | ||||
| -rw-r--r-- | tests/getcache_mem_corruption.py | 24 | ||||
| -rw-r--r-- | tests/old/__init__.py | 13 | ||||
| -rw-r--r-- | tests/old/apt-test.py (renamed from tests/apt-test.py) | 0 | ||||
| -rw-r--r-- | tests/old/cache.py (renamed from tests/cache.py) | 4 | ||||
| -rw-r--r-- | tests/old/depcache.py (renamed from tests/depcache.py) | 4 | ||||
| -rw-r--r-- | tests/old/hashsum_test.data (renamed from tests/hashsum_test.data) | 0 | ||||
| -rw-r--r-- | tests/old/hashsum_test_with_zero.data (renamed from tests/hashsum_test_with_zero.data) | bin | 7 -> 7 bytes | |||
| -rw-r--r-- | tests/old/lock.py (renamed from tests/lock.py) | 0 | ||||
| -rwxr-xr-x | tests/old/memleak.py (renamed from tests/memleak.py) | 8 | ||||
| -rw-r--r-- | tests/old/pkgproblemresolver.py (renamed from tests/pkgproblemresolver.py) | 6 | ||||
| -rw-r--r-- | tests/old/pkgrecords.py (renamed from tests/pkgrecords.py) | 6 | ||||
| -rw-r--r-- | tests/old/pkgsrcrecords.py (renamed from tests/pkgsrcrecords.py) | 4 | ||||
| -rwxr-xr-x | tests/old/refcount.py (renamed from tests/refcount.py) | 0 | ||||
| -rwxr-xr-x | tests/old/test_debextract.py (renamed from tests/test_debextract.py) | 0 | ||||
| -rw-r--r-- | tests/old/test_enhances.py (renamed from tests/test_enhances.py) | 0 | ||||
| -rw-r--r-- | tests/old/test_extract_archive.py (renamed from tests/test_extract_archive.py) | 0 | ||||
| -rw-r--r-- | tests/old/test_hashsums.py (renamed from tests/test_hashsums.py) | 0 | ||||
| -rw-r--r-- | tests/test_all.py | 33 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 34 | ||||
| -rw-r--r-- | tests/test_aptsources.py | 49 | ||||
| -rw-r--r-- | tests/test_aptsources_ports.py | 32 | ||||
| -rw-r--r-- | tests/test_cache_invocation.py | 30 | ||||
| -rw-r--r-- | tests/test_deps.py | 119 | ||||
| -rw-r--r-- | tests/test_hashes.py | 113 |
28 files changed, 417 insertions, 85 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..792d6005 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +# diff --git a/tests/data/sources.list b/tests/data/aptsources/sources.list index 5481d4f0..5481d4f0 100644 --- a/tests/data/sources.list +++ b/tests/data/aptsources/sources.list diff --git a/tests/data/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution index 0f40e85a..79224a34 100644 --- a/tests/data/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
\ No newline at end of file +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main diff --git a/tests/test-data-ports/sources.list b/tests/data/aptsources_ports/sources.list index a6b2f6ed..54f048b2 100644 --- a/tests/test-data-ports/sources.list +++ b/tests/data/aptsources_ports/sources.list @@ -6,12 +6,12 @@ # 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 +deb-src http://ports.ubuntu.com/ubuntu-ports/ 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 +deb-src http://ports.ubuntu.com/ubuntu-ports/ 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 @@ -19,9 +19,9 @@ deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted ## 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-src http://ports.ubuntu.com/ubuntu-ports/ hardy universe deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe -deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ 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 @@ -29,9 +29,9 @@ deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe ## 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-src http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse ## Uncomment the following two lines to add software from the 'backports' ## repository. @@ -41,7 +41,7 @@ deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse ## 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 +# deb-src http://ports.ubuntu.com/ubuntu-ports/ 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 @@ -56,4 +56,4 @@ 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 +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-proposed restricted main multiverse universe diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py deleted file mode 100644 index 42e9af00..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.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) - -if __name__ == "__main__": - unittest.main() 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/apt-test.py b/tests/old/apt-test.py index fac2ff43..fac2ff43 100644 --- a/tests/apt-test.py +++ b/tests/old/apt-test.py diff --git a/tests/cache.py b/tests/old/cache.py index 87a544e8..f0bf6761 100644 --- a/tests/cache.py +++ b/tests/old/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/old/depcache.py index 19aba680..0d59648e 100644 --- a/tests/depcache.py +++ b/tests/old/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/hashsum_test.data b/tests/old/hashsum_test.data index 19102815..19102815 100644 --- a/tests/hashsum_test.data +++ b/tests/old/hashsum_test.data diff --git a/tests/hashsum_test_with_zero.data b/tests/old/hashsum_test_with_zero.data Binary files differindex 2ec9a6df..2ec9a6df 100644 --- a/tests/hashsum_test_with_zero.data +++ b/tests/old/hashsum_test_with_zero.data diff --git a/tests/lock.py b/tests/old/lock.py index d45b3964..d45b3964 100644 --- a/tests/lock.py +++ b/tests/old/lock.py diff --git a/tests/memleak.py b/tests/old/memleak.py index 659091fc..5299f35f 100755 --- a/tests/memleak.py +++ b/tests/old/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/old/pkgproblemresolver.py index a21d8d9d..0d6d0611 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/old/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/old/pkgrecords.py index 5866847d..2fe6ad20 100644 --- a/tests/pkgrecords.py +++ b/tests/old/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/old/pkgsrcrecords.py index 77670540..2ea9dd3a 100644 --- a/tests/pkgsrcrecords.py +++ b/tests/old/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 diff --git a/tests/refcount.py b/tests/old/refcount.py index a29744ae..a29744ae 100755 --- a/tests/refcount.py +++ b/tests/old/refcount.py diff --git a/tests/test_debextract.py b/tests/old/test_debextract.py index 4ba498ae..4ba498ae 100755 --- a/tests/test_debextract.py +++ b/tests/old/test_debextract.py diff --git a/tests/test_enhances.py b/tests/old/test_enhances.py index 3eced9f9..3eced9f9 100644 --- a/tests/test_enhances.py +++ b/tests/old/test_enhances.py diff --git a/tests/test_extract_archive.py b/tests/old/test_extract_archive.py index ce202b06..ce202b06 100644 --- a/tests/test_extract_archive.py +++ b/tests/old/test_extract_archive.py diff --git a/tests/test_hashsums.py b/tests/old/test_hashsums.py index 0cf6beb7..0cf6beb7 100644 --- a/tests/test_hashsums.py +++ b/tests/old/test_hashsums.py diff --git a/tests/test_all.py b/tests/test_all.py new file mode 100644 index 00000000..d561a9ae --- /dev/null +++ b/tests/test_all.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# Copyright (C) 2009 Julian Andres Klode <jak@debian.org> +# +# 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 +import sys + +if __name__ == '__main__': + 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"): + 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]) + + unittest.main() diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py new file mode 100644 index 00000000..3c2961e1 --- /dev/null +++ b/tests/test_apt_cache.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# +# Copyright (C) 2010 Julian Andres Klode <jak@debian.org> +# +# 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 + + +class TestAptCache(unittest.TestCase): + """ test the apt cache """ + + def testAptCache(self): + """ simple test that iterates all packages and all dependencies """ + cache = apt.Cache() + # number is not meaningful and just need to be "big enough", + # the important bit is the test against __len__ + self.assertTrue(len(cache) > 100) + # go over the cache and all dependencies, just to see if + # that is possible and does not crash + for pkg in cache: + if pkg.candidate: + for or_dep in pkg.candidate.dependencies: + for dep in or_dep.or_dependencies: + name = dep.name + relation = dep.relation + preDepends = dep.pre_depend + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 3761f3ff..767f5244 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -3,24 +3,28 @@ 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 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"): + self.templates = os.path.abspath("../build/data/templates") + else: + self.templates = "/usr/share/python-apt/templates/" def testIsMirror(self): + """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", @@ -29,17 +33,21 @@ class TestAptSources(unittest.TestCase): self.assertFalse(no) def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() + """aptsources: Test sources.list parsing.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList(True, self.templates) self.assertEqual(len(sources.list), 6) # test load sources.list = [] - sources.load("data/sources.list") + sources.load("data/aptsources/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() + """aptsources: Test additions to sources.list""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + 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/", @@ -86,9 +94,10 @@ class TestAptSources(unittest.TestCase): self.assertEqual(found_universe, 1) def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() + """aptsources: Test matcher""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + 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 @@ -98,9 +107,10 @@ class TestAptSources(unittest.TestCase): 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() + """aptsources: Test distribution detection.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + 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 @@ -148,4 +158,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 09d6e9d9..991b532a 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -1,30 +1,32 @@ #!/usr/bin/env python - +import os 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): +class TestAptSourcesPorts(unittest.TestCase): + """Test aptsources on ports.ubuntu.com.""" - 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 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") + 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): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") - sources = aptsources.sourceslist.SourcesList() + """aptsources_ports: Test matcher.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list") + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", "8.04") distro.get_sources(sources) diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py new file mode 100644 index 00000000..6f4014de --- /dev/null +++ b/tests/test_cache_invocation.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +import unittest + +import apt_pkg +import apt.progress.base + + +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): + """cache_invocation: Test wrong invocation.""" + apt_cache = apt_pkg.Cache(apt.progress.base.OpProgress()) + + 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.""" + apt_cache = apt_pkg.Cache(apt.progress.base.OpProgress()) + apt_depcache = apt_pkg.DepCache(apt_cache) + +if __name__ == "__main__": + unittest.main() 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 <jak@debian.org> +# +# 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() diff --git a/tests/test_hashes.py b/tests/test_hashes.py new file mode 100644 index 00000000..e0aabe09 --- /dev/null +++ b/tests/test_hashes.py @@ -0,0 +1,113 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Julian Andres Klode <jak@debian.org> +# +# 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 sys + +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): + """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): + """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): + """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): + """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): + """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): + """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") + 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().""" + + 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): + """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): + """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): + """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): + """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()) + + +if __name__ == "__main__": + unittest.main() |
