summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-08-09 09:17:35 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-08-09 09:17:35 +0200
commit822ebea49fadca39591a566ad5ef7559d3adc26d (patch)
treec0101ef86777a4c06645b22ae770371c800f60ca
parent2fa02f88701da8277e6082942b928031a10cc08c (diff)
parent3a0e654a8a5935c148bc95a9f9cb5d7786aae825 (diff)
downloadpython-apt-822ebea49fadca39591a566ad5ef7559d3adc26d.tar.gz
merged from the mvo branch
-rw-r--r--apt/package.py8
-rw-r--r--debian/changelog9
-rw-r--r--tests/data/test-provides/etc/apt/sources.list1
-rw-r--r--tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages75
-rw-r--r--tests/data/test-provides/var/lib/dpkg/status0
-rw-r--r--tests/test_all.py4
-rw-r--r--tests/test_apt_cache.py16
7 files changed, 105 insertions, 8 deletions
diff --git a/apt/package.py b/apt/package.py
index 9223ed22..dbc5b23e 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -545,8 +545,8 @@ class Version(object):
base = os.path.basename(self._records.filename)
destfile = os.path.join(destdir, base)
if _file_is_same(destfile, self.size, self._records.md5_hash):
- print 'Ignoring already existing file:', destfile
- return
+ print('Ignoring already existing file: %s' % destfile)
+ return os.path.abspath(destfile)
acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress())
acqfile = apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash,
self.size, base, destfile=destfile)
@@ -555,7 +555,7 @@ class Version(object):
if acqfile.status != acqfile.STAT_DONE:
raise FetchError("The item %r could not be fetched: %s" %
(acqfile.destfile, acqfile.error_text))
- print self._records.filename
+
return os.path.abspath(destfile)
def fetch_source(self, destdir="", progress=None, unpack=True):
@@ -594,7 +594,7 @@ class Version(object):
if type_ == 'dsc':
dsc = destfile
if _file_is_same(destfile, size, md5):
- print 'Ignoring already existing file:', destfile
+ print('Ignoring already existing file: %s' % destfile)
continue
files.append(apt_pkg.AcquireFile(acq, src.index.archive_uri(path),
md5, size, base, destfile=destfile))
diff --git a/debian/changelog b/debian/changelog
index e41f0e36..e8e7f096 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,8 +14,15 @@ python-apt (0.8.1) UNRELEASED; urgency=low
experimental
* tests/test_apt_cache.py:
- fix test by providing proper fixture data
+ - fix test if sources.list is not readable (as is the case on some
+ PPA buildds)
+ * apt/package.py:
+ - fix py3 compatiblity with print
+ * tests/test_all.py:
+ - skip all tests if sources.list is not readable (as is the case on
+ some builds)
- -- Julian Andres Klode <jak@debian.org> Tue, 07 Jun 2011 14:00:22 +0200
+ -- Michael Vogt <mvo@debian.org> Tue, 09 Aug 2011 09:16:40 +0200
python-apt (0.8.0) unstable; urgency=low
diff --git a/tests/data/test-provides/etc/apt/sources.list b/tests/data/test-provides/etc/apt/sources.list
new file mode 100644
index 00000000..2955b5c3
--- /dev/null
+++ b/tests/data/test-provides/etc/apt/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu oneiric main
diff --git a/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages b/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages
new file mode 100644
index 00000000..f991cb96
--- /dev/null
+++ b/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages
@@ -0,0 +1,75 @@
+Package: exim4-daemon-light
+Priority: extra
+Section: mail
+Installed-Size: 1092
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+Original-Maintainer: Exim4 Maintainers <pkg-exim4-maintainers@lists.alioth.debian.org>
+Architecture: all
+Source: exim4
+Version: 4.76-2ubuntu1
+Replaces: mail-transport-agent
+Provides: mail-transport-agent
+Conflicts: mail-transport-agent
+Filename: pool/main/e/exim4/exim4-daemon-light_4.76-2ubuntu1_i386.deb
+Size: 451088
+MD5sum: 81795887e233ecfb3471e8a3da4c4b8b
+SHA1: da0202f7da88b9e9c5ee326a24c3fdd640543a5d
+SHA256: 5ffa03674b5198d1c0e9e0d9e3442cdd7fbe13226c7df91aa53def1f8b6c0d86
+Description: lightweight Exim MTA (v4) daemon
+ Exim (v4) is a mail transport agent. This package contains the exim4
+ daemon with only basic features enabled. It works well with the
+ standard setups that are provided by Debian and includes support for
+ TLS encryption and the dlopen patch to allow dynamic loading of a
+ local_scan function.
+ .
+ The Debian exim4 packages have their own web page,
+ http://pkg-exim4.alioth.debian.org/. There is also a Debian-specific
+ FAQ list. Information about the way the Debian packages are
+ configured can be found in
+ /usr/share/doc/exim4-base/README.Debian.gz, which additionally contains
+ information about the way the Debian binary packages are built. The
+ very extensive upstream documentation is shipped in
+ /usr/share/doc/exim4-base/spec.txt.gz. To repeat the debconf-driven
+ configuration process in a standard setup, invoke dpkg-reconfigure
+ exim4-config. There is a Debian-centered mailing list,
+ pkg-exim4-users@lists.alioth.debian.org. Please ask Debian-specific
+ questions there, and only write to the upstream exim-users mailing
+ list if you are sure that your question is not Debian-specific. You
+ can find the subscription web page on
+ http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users
+Homepage: http://www.exim.org/
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Origin: Ubuntu
+Supported: 18m
+
+Package: postfix
+Priority: optional
+Section: mail
+Installed-Size: 3472
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+Original-Maintainer: LaMont Jones <lamont@debian.org>
+Architecture: all
+Version: 2.8.3-1ubuntu1
+Replaces: mail-transport-agent
+Provides: default-mta, mail-transport-agent
+Recommends: python
+Suggests: procmail, postfix-mysql, postfix-pgsql, postfix-ldap, postfix-pcre, sasl2-bin, libsasl2-modules, dovecot-common, resolvconf, postfix-cdb, mail-reader, ufw
+Conflicts: libnss-db (<< 2.2-3), mail-transport-agent, smail
+Filename: pool/main/p/postfix/postfix_2.8.3-1ubuntu1_i386.deb
+Size: 1221834
+MD5sum: c4575f03ef0711cc744d394ae36f4a8c
+SHA1: f0f636c942981782cf23cee3d8a95aee188081b9
+SHA256: 13a4bfaf10c8addfc7dce01c0ea65bfbd6a759c4a2aaaafbae5855d099925fe0
+Description: High-performance mail transport agent
+ Postfix is Wietse Venema's mail transport agent that started life as an
+ alternative to the widely-used Sendmail program. Postfix attempts to
+ be fast, easy to administer, and secure, while at the same time being
+ sendmail compatible enough to not upset existing users. Thus, the outside
+ has a sendmail-ish flavor, but the inside is completely different.
+Homepage: http://www.postfix.org
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Origin: Ubuntu
+Supported: 18m
+Task: mail-server
+
+
diff --git a/tests/data/test-provides/var/lib/dpkg/status b/tests/data/test-provides/var/lib/dpkg/status
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/data/test-provides/var/lib/dpkg/status
diff --git a/tests/test_all.py b/tests/test_all.py
index 091581f8..f7b9dc8c 100644
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -34,6 +34,10 @@ def get_library_dir():
return os.path.abspath(library_dir)
if __name__ == '__main__':
+ if not os.access("/etc/apt/sources.list", os.R_OK):
+ sys.stderr.write("[tests] Skipping because sources.list is not readable\n")
+ sys.exit(0)
+
sys.stderr.write("[tests] Running on %s\n" % sys.version.replace("\n", ""))
dirname = os.path.dirname(__file__)
if dirname:
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):