summaryrefslogtreecommitdiff
path: root/test/test_execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-01-30 11:49:52 -0500
committerNed Batchelder <ned@nedbatchelder.com>2011-01-30 11:49:52 -0500
commit16943d29886df91300121fced970134d0c2b9806 (patch)
tree0e621681a8c90b7c7e3dabcaa0b241693129846b /test/test_execfile.py
parentfefc80883476d3974b3aee692ab274d1f563f7bb (diff)
downloadpython-coveragepy-git-16943d29886df91300121fced970134d0c2b9806.tar.gz
A bunch more places where a file close should be in a finally clause.
Diffstat (limited to 'test/test_execfile.py')
-rw-r--r--test/test_execfile.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/test_execfile.py b/test/test_execfile.py
index 2f28a069..f6e4dd7f 100644
--- a/test/test_execfile.py
+++ b/test/test_execfile.py
@@ -55,8 +55,10 @@ class RunTest(CoverageTest):
pylines = """# try newlines|print('Hello, world!')|""".split('|')
for nl in ('\n', '\r\n', '\r'):
fpy = open('nl.py', 'wb')
- fpy.write(nl.join(pylines).encode('utf-8'))
- fpy.close()
+ try:
+ 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)