diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-08 18:08:06 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-08 18:08:06 +0100 |
| commit | 2b0f6ff05d2c6937c1160c497cfb76b43f11f2db (patch) | |
| tree | a87e2639df12481e2046b835996628b53ec6325c /tests | |
| parent | b0995cca556668a4eced03e40e3edbc7362c2a10 (diff) | |
| parent | 350bb4a03d6562ddba12fbb0a34610aac7706b3c (diff) | |
| download | python-apt-2b0f6ff05d2c6937c1160c497cfb76b43f11f2db.tar.gz | |
merged from the mvo branch
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_apt_cache.py | 20 | ||||
| -rw-r--r-- | tests/test_debfile.py | 23 | ||||
| -rw-r--r-- | tests/test_utils.py | 1 |
3 files changed, 35 insertions, 9 deletions
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index db68ec63..6ec04ed5 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -55,8 +55,8 @@ class TestAptCache(unittest.TestCase): # 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: + for or_deps in pkg.candidate.dependencies: + for dep in or_deps: self.assertTrue(dep.name) self.assertTrue(isinstance(dep.relation, str)) self.assertTrue(dep.pre_depend in (True, False)) @@ -181,5 +181,21 @@ class TestAptCache(unittest.TestCase): apt_pkg.config.set("dir::etc::sourcelist", old_source_list) apt_pkg.config.set("dir::etc::sourceparts", old_source_parts) + def test_package_cmp(self): + cache = apt.Cache(rootdir="/") + l = [] + l.append(cache["libc6"]) + l.append(cache["xterm"]) + l.append(cache["apt"]) + l.sort() + self.assertEqual([p.name for p in l], + ["apt", "libc6", "xterm"]) + + def test_get_architectures(self): + main_arch = apt.apt_pkg.config.get("APT::Architecture") + arches = apt_pkg.get_architectures() + self.assertTrue(main_arch in arches) + + if __name__ == "__main__": unittest.main() diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 951c2afe..af04af26 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -87,12 +87,7 @@ class TestDebfilee(unittest.TestCase): self.assertEqual(deb["Maintainer"], "Samuel Lidén Borell <samuel@slbdata.se>") - def testContent(self): - # no python-debian for python3 yet, so fail gracefully - try: - import debian - except ImportError: - return + def test_content(self): # normal deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) @@ -119,6 +114,12 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") self.assertEqual(deb.filelist, ["./", "usr/", "usr/bin/"]) + def test_check_exception(self): + deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") + self.assertRaises(AttributeError, lambda: deb.missing_deps) + deb.check() + deb.missing_deps + def test_no_supported_data_tar(self): # ensure that a unknown data.tar.xxx raises a exception raised = False @@ -130,6 +131,16 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading # we need to support python2.6 self.assertTrue(raised) + def test_multiarch_deb(self): + if apt_pkg.get_architectures() != ["amd64", "i386"]: + logging.warn("skipping test because running on a non-multiarch system") + return + deb = apt.debfile.DebPackage("./data/test_debs/multiarch-test1_i386.deb") + res = deb.check() + # FIXME: do something sensible with the multiarch test + + + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() diff --git a/tests/test_utils.py b/tests/test_utils.py index 23511f32..26ee0bff 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,7 +7,6 @@ # notice and this notice are preserved. import sys -sys.path.insert(0, "..") import apt_pkg import apt.utils import datetime |
