summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-12-01 13:45:58 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-12-01 13:45:58 +0100
commitfb595849bc7149619b3e47b65f145a1f66fc7dbe (patch)
tree51c92230c4d404e24a6adca1178a65c4d0297b73
parentc8bfdda85fbd2df250fbc6d3faeb2bd5875a77d6 (diff)
downloadpython-apt-fb595849bc7149619b3e47b65f145a1f66fc7dbe.tar.gz
fix debfile binary test for py3
-rw-r--r--apt/debfile.py11
-rw-r--r--tests/test_debfile.py5
2 files changed, 9 insertions, 7 deletions
diff --git a/apt/debfile.py b/apt/debfile.py
index 104b0814..4a82842a 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -525,12 +525,19 @@ class DebPackage(object):
@staticmethod
def to_strish(in_data):
+ # helper for py3 compat, in_data is str in py2 and bytes in py3
+ def my_ord(c):
+ if type(c) == int:
+ return c
+ else:
+ return ord(c)
+ # convert
s = ""
for c in in_data:
- if ord(c) < 10 or ord(c) > 127:
+ if my_ord(c) < 10 or my_ord(c) > 127:
s += " "
else:
- s += c
+ s += chr(c)
return s
def _get_content(self, part, name, auto_decompress=True, auto_hex=True):
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index 56410153..70979689 100644
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -88,11 +88,6 @@ class TestDebfilee(unittest.TestCase):
"Samuel Lidén Borell <samuel@slbdata.se>")
def test_content(self):
- # no python-debian for python3 yet, so fail gracefully
- try:
- import debian
- except ImportError:
- return
# normal
deb = apt.debfile.DebPackage(cache=self.cache)
deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb"))