summaryrefslogtreecommitdiff
path: root/tests/test_tagfile.py
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-06-10 16:44:03 +0200
committerMichael Vogt <mvo@debian.org>2014-06-10 16:44:03 +0200
commit1b6b123a052ca2d53e90b62da09ce300d701265a (patch)
tree2279c1f66853c40413a1bfb1c758368037d8b7c1 /tests/test_tagfile.py
parent9de6a183f09f0d0adbcc5817872c5a0024f5ef47 (diff)
parent887406dbb341ed684cd898f15b133baac252bc25 (diff)
downloadpython-apt-1b6b123a052ca2d53e90b62da09ce300d701265a.tar.gz
Merge remote-tracking branch 'mvo/feature/srcrec-enum' into debian/sid
Conflicts: debian/control
Diffstat (limited to 'tests/test_tagfile.py')
-rw-r--r--tests/test_tagfile.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_tagfile.py b/tests/test_tagfile.py
index 6ff6a32a..ff7d81cd 100644
--- a/tests/test_tagfile.py
+++ b/tests/test_tagfile.py
@@ -132,5 +132,29 @@ class TestTagFile(unittest.TestCase):
self.assertEqual(
value.encode("ISO-8859-1"), tagfile.section["Maintainer"])
+ @unittest.skipIf(not os.path.exists("/proc/self/fd"), "need /proc/self/fd")
+ def test_leak(self):
+ # clenaup gc first
+ import gc
+ gc.collect()
+ # see what fds we have
+ fds = os.listdir("/proc/self/fd")
+ testfile = __file__
+ tagf = apt_pkg.TagFile(testfile)
+ tagf.step()
+ print("1", tagf.section)
+ sec = tagf.section
+ print("2", sec)
+ print(gc.get_referrers(sec))
+ self.assertTrue(str(tagf.section).startswith("#!/usr/bin/python"))
+ del tagf
+ print(gc.get_referrers(sec))
+ # sec is still ok
+ print("42", sec)
+ self.assertTrue(str(sec).startswith("#!/usr/bin/python"))
+ # ensure fd is closed
+ self.assertEqual(fds, os.listdir("/proc/self/fd"))
+
+
if __name__ == "__main__":
unittest.main()