diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-10-15 11:27:49 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-10-15 11:27:49 +0200 |
| commit | 3a7246ab8faa36eb270f28e6b47e1608e587365a (patch) | |
| tree | 35bbeb9ad525116db36309887a6b99d624ea0329 /tests | |
| parent | 7a7722a91bd80572daf5d5f7f377b7b189e533bf (diff) | |
| download | python-apt-3a7246ab8faa36eb270f28e6b47e1608e587365a.tar.gz | |
close cache on (re)open
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_apt_cache.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index c850cec2..22c4e871 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -100,6 +100,23 @@ class TestAptCache(TestCase): self.assertEqual(fds_before_open, fds_after_close) self.assertEqual(unclosed_fd, set()) + def test_cache_open_twice_leaks_fds(self): + cache = apt.Cache() + fds_before_open = get_open_file_descriptors() + cache.open() + fds_after_open_twice = get_open_file_descriptors() + self.assertEqual(fds_before_open, fds_after_open_twice) + + @if_sources_list_is_readable + def test_cache_delete_leasks_fds(self): + fds_before_open = get_open_file_descriptors() + cache = apt.Cache() + del cache + import gc + gc.collect() + fds_after_delete = get_open_file_descriptors() + self.assertEqual(fds_before_open, fds_after_delete) + @if_sources_list_is_readable def test_cache_close_download_fails(self): cache = apt.Cache() |
