diff options
| -rw-r--r-- | debian/changelog | 5 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 30 |
2 files changed, 28 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog index 1cb722b6..0e8ca556 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,16 @@ python-apt (0.8.8.1) UNRELEASED; urgency=low + [ Michael Vogt ] * python/tag.cc: - make TagSecString_FromStringAndSize, TagSecString_FromString static, thanks to jcristau * python/cache.cc: - add "Codename" to PackageFile object * add dep8 style autopkgtest support + + [ Jason Conti ] + * lp:~jconti/python-apt/closeable-cache: + - add apt.Cache.close() method -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 15 Oct 2012 10:03:21 +0200 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index fc429cf3..c850cec2 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -16,6 +16,12 @@ import sys import tempfile import unittest +if sys.version_info[0] == 2 and sys.version_info[1] == 6: + from unittest2 import TestCase +else: + from unittest import TestCase + + from test_all import get_library_dir sys.path.insert(0, get_library_dir()) @@ -41,7 +47,7 @@ def get_open_file_descriptors(): return set(map(int, fds)) -class TestAptCache(unittest.TestCase): +class TestAptCache(TestCase): """ test the apt cache """ def setUp(self): @@ -80,18 +86,28 @@ class TestAptCache(unittest.TestCase): self.assertEqual(r['Package'], pkg.shortname) self.assertTrue('Version' in r) self.assertTrue(len(r['Description']) > 0) - self.assertTrue(str(r).startswith('Package: %s\n' % pkg.shortname)) + self.assertTrue( + str(r).startswith('Package: %s\n' % pkg.shortname)) @if_sources_list_is_readable - def test_closeable_cache(self): - fd_0 = get_open_file_descriptors() + def test_cache_close_leak_fd(self): + fds_before_open = get_open_file_descriptors() cache = apt.Cache() - opened_fd = get_open_file_descriptors().difference(fd_0) + opened_fd = get_open_file_descriptors().difference(fds_before_open) cache.close() - fd_1 = get_open_file_descriptors() - unclosed_fd = opened_fd.intersection(fd_1) + fds_after_close = get_open_file_descriptors() + unclosed_fd = opened_fd.intersection(fds_after_close) + self.assertEqual(fds_before_open, fds_after_close) self.assertEqual(unclosed_fd, set()) + @if_sources_list_is_readable + def test_cache_close_download_fails(self): + cache = apt.Cache() + self.assertEqual(cache.required_download, 0) + cache.close() + with self.assertRaises(apt.cache.CacheClosedException): + cache.required_download + def test_get_provided_packages(self): apt.apt_pkg.config.set("Apt::architecture", "i386") cache = apt.Cache(rootdir="./data/test-provides/") |
