Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
0b368ad3
Commit
0b368ad3
authored
Aug 29, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some file open/close usages in the test runner.
parent
036637f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
runtests.py
runtests.py
+17
-15
No files found.
runtests.py
View file @
0b368ad3
...
@@ -948,7 +948,9 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -948,7 +948,9 @@ class CythonCompileTestCase(unittest.TestCase):
if self.preparse and self.preparse != 'id':
if self.preparse and self.preparse != 'id':
preparse_func = globals()[self.preparse]
preparse_func = globals()[self.preparse]
def copy(src, dest):
def copy(src, dest):
open(dest, 'w').write(preparse_func(open(src).read()))
with open(src) as fin:
with open(dest, 'w') as fout:
fout.write(preparse_func(fin.read()))
else:
else:
# use symlink on Unix, copy on Windows
# use symlink on Unix, copy on Windows
try:
try:
...
@@ -969,11 +971,11 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -969,11 +971,11 @@ class CythonCompileTestCase(unittest.TestCase):
def split_source_and_output(self, test_directory, module, workdir):
def split_source_and_output(self, test_directory, module, workdir):
source_file = self.find_module_source_file(os.path.join(test_directory, module) + '.pyx')
source_file = self.find_module_source_file(os.path.join(test_directory, module) + '.pyx')
source_and_output = io_open(source_file, 'r', encoding='ISO-8859-1')
with io_open(source_file, 'r', encoding='ISO-8859-1') as source_and_output:
error_writer = warnings_writer = None
error_writer = warnings_writer = None
try:
out = io_open(os.path.join(workdir, module + os.path.splitext(source_file)[1]),
out = io_open(os.path.join(workdir, module + os.path.splitext(source_file)[1]),
'w', encoding='ISO-8859-1')
'w', encoding='ISO-8859-1')
try:
for line in source_and_output:
for line in source_and_output:
if line.startswith("_ERRORS"):
if line.startswith("_ERRORS"):
out.close()
out.close()
...
@@ -984,7 +986,7 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -984,7 +986,7 @@ class CythonCompileTestCase(unittest.TestCase):
else:
else:
out.write(line)
out.write(line)
finally:
finally:
source_and_outp
ut.close()
o
ut.close()
return (error_writer.geterrors() if error_writer else [],
return (error_writer.geterrors() if error_writer else [],
warnings_writer.geterrors() if warnings_writer else [])
warnings_writer.geterrors() if warnings_writer else [])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment