Commit a9963a76 authored by Stefan Behnel's avatar Stefan Behnel

fix some pyregr tests by copying required (data) files

--HG--
extra : amend_source : b920a1b9cf4249bb95a7f1a310222080c26dc326
parent bf2cf6fd
...@@ -332,9 +332,18 @@ def parse_tags(filepath): ...@@ -332,9 +332,18 @@ def parse_tags(filepath):
f.close() f.close()
return tags return tags
list_unchanging_dir = memoize(lambda x: os.listdir(x)) list_unchanging_dir = memoize(lambda x: os.listdir(x))
@memoize
def _list_pyregr_data_files(test_directory):
splitext = os.path.splitext
data_file_extensions = ('.txt', '.pem', '.db', '.html')
return [filename for filename in list_unchanging_dir(test_directory)
if splitext(filename)[1] in data_file_extensions] + ['__init__.py']
def import_ext(module_name, file_path=None): def import_ext(module_name, file_path=None):
if file_path: if file_path:
import imp import imp
...@@ -642,8 +651,9 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -642,8 +651,9 @@ class CythonCompileTestCase(unittest.TestCase):
def copy_files(self, test_directory, target_directory, file_list): def copy_files(self, test_directory, target_directory, file_list):
for filename in file_list: for filename in file_list:
shutil.copy(os.path.join(test_directory, filename), file_path = os.path.join(test_directory, filename)
target_directory) if os.path.exists(file_path):
shutil.copy(file_path, target_directory)
def source_files(self, workdir, module_name, file_list): def source_files(self, workdir, module_name, file_list):
return ([self.build_target_filename(module_name)] + return ([self.build_target_filename(module_name)] +
...@@ -1057,6 +1067,9 @@ class CythonPyregrTestCase(CythonRunTestCase): ...@@ -1057,6 +1067,9 @@ class CythonPyregrTestCase(CythonRunTestCase):
set_initial_path="SOURCEFILE")) set_initial_path="SOURCEFILE"))
patch_inspect_isfunction() patch_inspect_isfunction()
def related_files(self, test_directory, module_name):
return _list_pyregr_data_files(test_directory)
def _run_unittest(self, result, *classes): def _run_unittest(self, result, *classes):
"""Run tests from unittest.TestCase-derived classes.""" """Run tests from unittest.TestCase-derived classes."""
valid_types = (unittest.TestSuite, unittest.TestCase) valid_types = (unittest.TestSuite, unittest.TestCase)
......
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