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 /tests | |
| parent | 9da50582230f21c9267a25eb92dbf3c080dfcafc (diff) | |
| parent | b94455e7afd0e08ce1a8aab890dbee0d42566d7b (diff) | |
| download | python-apt-12ba28e618916bdb418d7e0ed2c8e368ead7e625.tar.gz | |
fix py3 compatibility
Diffstat (limited to 'tests')
| -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 |
3 files changed, 24 insertions, 12 deletions
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 |
