diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-07-06 09:56:20 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-07-06 09:56:20 +0200 |
| commit | 12ba28e618916bdb418d7e0ed2c8e368ead7e625 (patch) | |
| tree | 17c2d6f0e53987eadc3b911394d26ea1a355d5b6 | |
| parent | 9da50582230f21c9267a25eb92dbf3c080dfcafc (diff) | |
| parent | b94455e7afd0e08ce1a8aab890dbee0d42566d7b (diff) | |
| download | python-apt-12ba28e618916bdb418d7e0ed2c8e368ead7e625.tar.gz | |
fix py3 compatibility
| -rw-r--r-- | apt/debfile.py | 3 | ||||
| -rw-r--r-- | debian/changelog | 1 | ||||
| -rw-r--r-- | tests/test_all.py | 32 | ||||
| -rw-r--r-- | tests/test_debfile.py | 4 | ||||
| -rw-r--r-- | tests/test_debs/gdebi-test6.deb | bin | 4312 -> 600 bytes |
5 files changed, 27 insertions, 13 deletions
diff --git a/apt/debfile.py b/apt/debfile.py index 06854cf2..f969f485 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -62,7 +62,8 @@ class DebPackage(object): self.filename = filename self._debfile = apt_inst.DebFile(open(self.filename)) control = self._debfile.control.extractdata("control") - self._sections = apt_pkg.TagSection(control) + # hm, 'replace' is probably better but python2.6 test fail with that + self._sections = apt_pkg.TagSection(control.decode("UTF-8", 'ignore')) self.pkgname = self._sections["Package"] def __getitem__(self, key): diff --git a/debian/changelog b/debian/changelog index e82c0487..98be965a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ python-apt (0.7.96) UNRELEASED; urgency=low * apt/debfile.py: - check if the debfiles provides are in conflict with the systems packages + - fix py3 compatibility * tests/test_debs/*.deb, tests/test_debfile.py: - add automatic test based on the test debs from gdebi diff --git a/tests/test_all.py b/tests/test_all.py index d561a9ae..d6370747 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -9,21 +9,29 @@ 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__)) +def get_library_dir(): # 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, + if not os.path.exists("../build"): + return None + 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 ""), + else: + library_dir = "../build/lib%s%s" % ((sys.pydebug and "_d" or ""), plat_specifier) + return os.path.abspath(library_dir) + +if __name__ == '__main__': + sys.stderr.write("[tests] Running on %s\n" % sys.version.replace("\n", "")) + dirname = os.path.dirname(__file__) + if dirname: + os.chdir(dirname) + library_dir = get_library_dir() + if library_dir: sys.path.insert(0, os.path.abspath(library_dir)) for path in os.listdir('.'): diff --git a/tests/test_debfile.py b/tests/test_debfile.py index b9ed89c3..56bbba9f 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -10,6 +10,10 @@ import os import logging import unittest +from test_all import get_library_dir +import sys +sys.path.insert(0, get_library_dir()) + import apt.debfile diff --git a/tests/test_debs/gdebi-test6.deb b/tests/test_debs/gdebi-test6.deb Binary files differindex 32fd1800..8ceacadc 100644 --- a/tests/test_debs/gdebi-test6.deb +++ b/tests/test_debs/gdebi-test6.deb |
