summaryrefslogtreecommitdiff
path: root/tests/test_apt_cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-08-08 13:46:29 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-08-08 13:46:29 +0200
commitbbde74767b7c1b6309d2db6469d18cc5fa3b697a (patch)
tree0d19d6b4aed1d37b612f19b5f5396bbd7373db39 /tests/test_apt_cache.py
parentc44f1fc99e2afd12c79825cdb8e7d287d400bba7 (diff)
parent68860341da1d5e328b66e85f7fdbdc8f54748cb9 (diff)
downloadpython-apt-bbde74767b7c1b6309d2db6469d18cc5fa3b697a.tar.gz
merged from the mvo branch
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):