summaryrefslogtreecommitdiff
path: root/tests/test_execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
commit249ad14dfedbe45919b48dbbff445394a64d985c (patch)
treef88f6356df0087c28e8d18a434e5e9142359352f /tests/test_execfile.py
parentf0459a54bb3e703691359aa3078a8234173ec361 (diff)
downloadpython-coveragepy-249ad14dfedbe45919b48dbbff445394a64d985c.tar.gz
with statements: no more finally close
Diffstat (limited to 'tests/test_execfile.py')
-rw-r--r--tests/test_execfile.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/test_execfile.py b/tests/test_execfile.py
index 24c521b..ca13d7c 100644
--- a/tests/test_execfile.py
+++ b/tests/test_execfile.py
@@ -54,11 +54,8 @@ class RunFileTest(CoverageTest):
# Make sure we can read any sort of line ending.
pylines = """# try newlines|print('Hello, world!')|""".split('|')
for nl in ('\n', '\r\n', '\r'):
- fpy = open('nl.py', 'wb')
- try:
+ with open('nl.py', 'wb') as fpy:
fpy.write(nl.join(pylines).encode('utf-8'))
- finally:
- fpy.close()
run_python_file('nl.py', ['nl.py'])
self.assertEqual(self.stdout(), "Hello, world!\n"*3)