Commit 3f5f824b authored by Stefan Behnel's avatar Stefan Behnel

enable forked test runs for pyregr test suite

parent 31d50eb9
......@@ -588,8 +588,15 @@ class CythonRunTestCase(CythonCompileTestCase):
self.run_doctests(self.module, result)
def run_doctests(self, module_name, result):
if sys.version_info[0] >= 3 or not hasattr(os, 'fork') or not self.fork:
doctest.DocTestSuite(module_name).run(result)
def run_test(result):
tests = doctest.DocTestSuite(module_name)
tests.run(result)
run_forked_test(result, run_test, self.shortDescription(), self.fork)
def run_forked_test(result, run_func, test_name, fork=True):
if sys.version_info[0] >= 3 or not hasattr(os, 'fork') or not fork:
run_test(result)
gc.collect()
return
......@@ -604,15 +611,14 @@ class CythonRunTestCase(CythonCompileTestCase):
tests = None
try:
partial_result = PartialTestResult(result)
tests = doctest.DocTestSuite(module_name)
tests.run(partial_result)
run_func(partial_result)
gc.collect()
except Exception:
if tests is None:
# importing failed, try to fake a test class
tests = _FakeClass(
failureException=sys.exc_info()[1],
_shortDescription=self.shortDescription(),
_shortDescription=test_name,
module_name=None)
partial_result.addError(tests, sys.exc_info())
result_code = 1
......@@ -773,6 +779,7 @@ class CythonPyregrTestCase(CythonRunTestCase):
except ImportError: # Py3k
from test import support
def run_test(result):
def run_unittest(*classes):
return self._run_unittest(result, *classes)
def run_doctest(module, verbosity=None):
......@@ -788,6 +795,8 @@ class CythonPyregrTestCase(CythonRunTestCase):
except (unittest.SkipTest, support.ResourceDenied):
result.addSkip(self, 'ok')
run_forked_test(result, run_test, self.shortDescription(), self.fork)
include_debugger = sys.version_info[:2] > (2, 5)
def collect_unittests(path, module_prefix, suite, selectors):
......
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