Skip to content

Commit c16ef98

Browse files
committed
Use open context manager
Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 2602786 commit c16ef98

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

testtools/run.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@ def __init__(
205205
# OptimisingTestSuite.add, but with a standard protocol).
206206
# This is needed because the load_tests hook allows arbitrary
207207
# suites, even if that is rarely used.
208-
source = open(self.load_list, "rb")
209-
try:
208+
with open(self.load_list, "rb") as source:
210209
lines = source.readlines()
211-
finally:
212-
source.close()
213210
test_ids = {line.strip().decode("utf-8") for line in lines}
214211
self.test = filter_by_ids(self.test, test_ids)
215212
if not self.listtests:

0 commit comments

Comments
 (0)