From 249ad14dfedbe45919b48dbbff445394a64d985c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 20 Oct 2013 07:58:57 -0400 Subject: with statements: no more finally close --- tests/test_execfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tests/test_execfile.py') 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) -- cgit v1.2.1