From 980c1cbd0d883c9e429aaa64633680456a0a776d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 27 Aug 2010 15:06:54 +0200 Subject: add "provides" property to the apt.Version objects --- tests/test_apt_cache.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index a43e92d2..2ace0201 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -1,6 +1,7 @@ #!/usr/bin/python # # Copyright (C) 2010 Julian Andres Klode +# 2010 Michael Vogt # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -50,6 +51,7 @@ class TestAptCache(unittest.TestCase): # a true virtual pkg l = cache.get_providing_packages("mail-transport-agent") self.assertTrue(len(l) > 0) + self.assertTrue("postfix" in [p.name for p in l]) # this is a not virtual (transitional) package provided by another l = cache.get_providing_packages("scrollkeeper") self.assertEqual(l, []) @@ -58,6 +60,7 @@ class TestAptCache(unittest.TestCase): l = cache.get_providing_packages("scrollkeeper", include_nonvirtual=True) self.assertTrue(len(l), 1) + self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides) def test_dpkg_journal_dirty(self): -- cgit v1.2.3 From aaaa4e322280c780711f4242ed3d01c9e9d28af6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 14:40:22 +0200 Subject: add content reading test --- tests/data/test_debs/gdebi-test11.deb | Bin 0 -> 634 bytes tests/test_debfile.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 tests/data/test_debs/gdebi-test11.deb (limited to 'tests') diff --git a/tests/data/test_debs/gdebi-test11.deb b/tests/data/test_debs/gdebi-test11.deb new file mode 100644 index 00000000..af9b441f Binary files /dev/null and b/tests/data/test_debs/gdebi-test11.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 5874dfc4..04a5e0b3 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -77,6 +77,12 @@ class TestDebfilee(unittest.TestCase): "Unexpected result for package '%s' (got %s wanted %s)\n%s" % ( filename, res, expected_res, deb._failure_string)) + def testContent(self): + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) + self.assertEqual('#!/bin/sh\necho "test"\n', + deb.data_content("usr/bin/test")) + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() -- cgit v1.2.3 From 306d93a0257ddb2442d03df05952ce5bacbc5802 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 15:12:54 +0200 Subject: tests/test_debfile.py: add test for binary reading --- tests/data/test_debs/gdebi-test12.deb | Bin 0 -> 966 bytes tests/test_debfile.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 tests/data/test_debs/gdebi-test12.deb (limited to 'tests') diff --git a/tests/data/test_debs/gdebi-test12.deb b/tests/data/test_debs/gdebi-test12.deb new file mode 100644 index 00000000..36544cc7 Binary files /dev/null and b/tests/data/test_debs/gdebi-test12.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 04a5e0b3..72b9100c 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -78,10 +78,16 @@ class TestDebfilee(unittest.TestCase): filename, res, expected_res, deb._failure_string)) def testContent(self): + # normal deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) self.assertEqual('#!/bin/sh\necho "test"\n', deb.data_content("usr/bin/test")) + # binary + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb")) + self.assertEqual('#!/bin/sh\necho "test"\n', + deb.data_content("usr/bin/binary")) if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) -- cgit v1.2.3 From 96476d01e881f52d53a70f1ae700594a0f321056 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 15:18:42 +0200 Subject: * apt/debfile.py: - fix error when reading binary content and add regresion test --- apt/debfile.py | 4 ++-- debian/changelog | 2 ++ tests/test_debfile.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/apt/debfile.py b/apt/debfile.py index 33f0f04d..73f7d88e 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -512,7 +512,7 @@ class DebPackage(object): return sorted(content) @staticmethod - def to_hex(self, in_data): + def to_hex(in_data): hex = "" for (i, c) in enumerate(in_data): if i%80 == 0: @@ -521,7 +521,7 @@ class DebPackage(object): return hex @staticmethod - def to_strish(self, in_data): + def to_strish(in_data): s = "" for c in in_data: if ord(c) < 10 or ord(c) > 127: diff --git a/debian/changelog b/debian/changelog index 9478bf89..7fd04b41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ python-apt (0.7.97) UNRELEASED; urgency=low PartialPresent() from pkgAcquire(). This follows the change in libapt. * add "provides" property to the apt.Version objects + * apt/debfile.py: + - fix error when reading binary content and add regresion test -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 72b9100c..42cda6f6 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -86,8 +86,9 @@ class TestDebfilee(unittest.TestCase): # binary deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb")) - self.assertEqual('#!/bin/sh\necho "test"\n', - deb.data_content("usr/bin/binary")) + content = deb.data_content("usr/bin/binary") + self.assertTrue(content.startswith("Automatically converted to printable ascii:\n\x7fELF ")) + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) -- cgit v1.2.3