Commit 356808fe authored by Stefan Behnel's avatar Stefan Behnel

test runner: close files immediately after use

parent abaa1710
...@@ -316,6 +316,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -316,6 +316,7 @@ class CythonCompileTestCase(unittest.TestCase):
source_file = os.path.join(test_directory, module) + '.pyx' source_file = os.path.join(test_directory, module) + '.pyx'
source_and_output = codecs.open( source_and_output = codecs.open(
self.find_module_source_file(source_file), 'rU', 'ISO-8859-1') self.find_module_source_file(source_file), 'rU', 'ISO-8859-1')
try:
out = codecs.open(os.path.join(workdir, module + '.pyx'), out = codecs.open(os.path.join(workdir, module + '.pyx'),
'w', 'ISO-8859-1') 'w', 'ISO-8859-1')
for line in source_and_output: for line in source_and_output:
...@@ -325,9 +326,12 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -325,9 +326,12 @@ class CythonCompileTestCase(unittest.TestCase):
out = ErrorWriter() out = ErrorWriter()
else: else:
out.write(line) out.write(line)
finally:
source_and_output.close()
try: try:
geterrors = out.geterrors geterrors = out.geterrors
except AttributeError: except AttributeError:
out.close()
return [] return []
else: else:
return geterrors() return geterrors()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment