summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-05-15 12:28:58 +0200
committerJulian Andres Klode <jak@debian.org>2015-05-15 12:28:58 +0200
commitbdbbe156c7aabe231343c909d4bfc5b5ac4c54ce (patch)
tree38d98a2e6c99f67367578ec5b3a85874d847319a
parentabd58af3ef23df25870945192bfd3835c09ed87b (diff)
downloadpython-apt-bdbbe156c7aabe231343c909d4bfc5b5ac4c54ce.tar.gz
tests/test_tagfile.py: Close files we opened to prevent leakage
This bug was initially experienced in the Ubuntu automatic package testing environment, and they fixed it in 0.9.4ubuntu1 with the same (obvious) patch. The bug was reported in Debian as #785337 with a different patch. Compared to the patch suggested in the bug tracker, this version is more idiomatic Python. Closes: #785337
-rw-r--r--tests/test_tagfile.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_tagfile.py b/tests/test_tagfile.py
index 1ac20624..029e2946 100644
--- a/tests/test_tagfile.py
+++ b/tests/test_tagfile.py
@@ -34,16 +34,16 @@ class TestOpenMaybeClearSigned(unittest.TestCase):
basepath = os.path.dirname(__file__)
fd = apt_pkg.open_maybe_clear_signed_file(
os.path.join(basepath, "./data/test_debs/hello_2.5-1.dsc"))
- f = os.fdopen(fd)
- data = f.read()
+ with os.fdopen(fd) as f:
+ data = f.read()
self.assertTrue(data.startswith("Format: 1.0\n"))
def test_open_normal(self):
basepath = os.path.dirname(__file__)
fd = apt_pkg.open_maybe_clear_signed_file(
os.path.join(basepath, "./data/misc/foo_Release"))
- f = os.fdopen(fd)
- data = f.read()
+ with os.fdopen(fd) as f:
+ data = f.read()
self.assertTrue(data.startswith("Origin: Ubuntu\n"))
def xtest_open_does_not_exit(self):