summaryrefslogtreecommitdiff
path: root/tests/test_apt_cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-08-08 13:45:22 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-08-08 13:45:22 +0200
commit68860341da1d5e328b66e85f7fdbdc8f54748cb9 (patch)
treee9300eb5be38a079129ba54f24a59d6642ad2272 /tests/test_apt_cache.py
parent2fa02f88701da8277e6082942b928031a10cc08c (diff)
downloadpython-apt-68860341da1d5e328b66e85f7fdbdc8f54748cb9.tar.gz
tests/test_apt_cache.py: make the test work on PPA buildd chroots
Diffstat (limited to 'tests/test_apt_cache.py')
-rw-r--r--tests/test_apt_cache.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 916a43cb..2f812059 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -17,9 +17,17 @@ sys.path.insert(0, get_library_dir())
import apt
import apt_pkg
-import copy
import shutil
import glob
+import logging
+
+def if_sources_list_is_readable(f):
+ def wrapper(*args, **kwargs):
+ if os.access("/etc/apt/sources.list", os.R_OK):
+ f(*args, **kwargs)
+ else:
+ logging.warn("skipping '%s' because sources.list is not readable" % f)
+ return wrapper
class TestAptCache(unittest.TestCase):
""" test the apt cache """
@@ -36,6 +44,7 @@ class TestAptCache(unittest.TestCase):
for item in self._cnf:
apt_pkg.config.set(item, self._cnf[item])
+ @if_sources_list_is_readable
def test_apt_cache(self):
"""cache: iterate all packages and all dependencies """
cache = apt.Cache()
@@ -79,7 +88,7 @@ class TestAptCache(unittest.TestCase):
cache = highlevel_cache._cache
l = cache["mail-transport-agent"].provides_list
# arbitrary number, just needs to be higher enough
- self.assertTrue(len(l) > 5)
+ self.assertEqual(len(l), 2)
for (providesname, providesver, version) in l:
self.assertEqual(providesname, "mail-transport-agent")
if version.parent_pkg.name == "postfix":
@@ -87,7 +96,7 @@ class TestAptCache(unittest.TestCase):
else:
self.assertNotReached()
-
+ @if_sources_list_is_readable
def test_dpkg_journal_dirty(self):
# create tmp env
tmpdir = tempfile.mkdtemp()
@@ -106,6 +115,7 @@ class TestAptCache(unittest.TestCase):
open(os.path.join(dpkg_dir,"updates","000"), "w").close()
self.assertTrue(cache.dpkg_journal_dirty)
+ @if_sources_list_is_readable
def test_apt_update(self):
rootdir = "./data/tmp"
if os.path.exists(rootdir):