summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Cardona <remi.cardona@logilab.fr>2015-09-10 16:48:18 +0200
committerRémi Cardona <remi.cardona@logilab.fr>2015-09-10 16:48:18 +0200
commita71b1b5fc417aaa6b463fa51f47299f9126807e3 (patch)
tree562de343c1e72d9b2ed5d4b9a0eef78455a57370
parent44c910be971318e8c8bb6abec67ae991211b9d7a (diff)
downloadlogilab-common-a71b1b5fc417aaa6b463fa51f47299f9126807e3.tar.gz
[tests] Fix resource leak
-rw-r--r--test/unittest_testlib.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py
index 65cc0a2..fe2e31a 100644
--- a/test/unittest_testlib.py
+++ b/test/unittest_testlib.py
@@ -135,10 +135,12 @@ class TestlibTC(TestCase):
self.assertRaises(AssertionError, self.tc.assertMultiLineEqual, 'toto\ntiti', 'toto\n titi\n')
foo = join(dirname(__file__), 'data', 'foo.txt')
spam = join(dirname(__file__), 'data', 'spam.txt')
- text1 = open(foo).read()
+ with open(foo) as fobj:
+ text1 = fobj.read()
self.tc.assertMultiLineEqual(text1, text1)
self.tc.assertMultiLineEqual(text1, text1)
- text2 = open(spam).read()
+ with open(spam) as fobj:
+ text2 = fobj.read()
self.assertRaises(AssertionError, self.tc.assertMultiLineEqual, text1, text2)
self.assertRaises(AssertionError, self.tc.assertMultiLineEqual, text1, text2)