Skip to content

Commit ad8e7bb

Browse files
committed
Use context manager
1 parent c0c988d commit ad8e7bb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fluent.runtime/tests/test_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ def patch_me(a, b):
2727
def assertFileIs(self, filename, expect_contents):
2828
"""
2929
expect_contents is None: Expect file does not exist
30-
expect_contents is a str: Expect file contents to match
30+
expect_contents is a str: Expect file to exist and contents to match
3131
"""
3232
if expect_contents is None:
3333
self.assertFalse(os.path.isfile(filename),
3434
f"Expected {filename} to not exist.")
3535
else:
3636
self.assertTrue(os.path.isfile(filename),
3737
f"Expected {filename} to exist.")
38-
self.assertEqual(codecs.open(filename, "r", "utf-8").read(),
39-
expect_contents)
38+
with codecs.open(filename, "r", "utf-8") as f:
39+
self.assertEqual(f.read(), expect_contents)

0 commit comments

Comments
 (0)