diff options
author | Rémi Cardona <remi.cardona@logilab.fr> | 2015-09-10 16:48:18 +0200 |
---|---|---|
committer | Rémi Cardona <remi.cardona@logilab.fr> | 2015-09-10 16:48:18 +0200 |
commit | a71b1b5fc417aaa6b463fa51f47299f9126807e3 (patch) | |
tree | 562de343c1e72d9b2ed5d4b9a0eef78455a57370 | |
parent | 44c910be971318e8c8bb6abec67ae991211b9d7a (diff) | |
download | logilab-common-a71b1b5fc417aaa6b463fa51f47299f9126807e3.tar.gz |
[tests] Fix resource leak
-rw-r--r-- | test/unittest_testlib.py | 6 |
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) |