Commit 34456bb9 authored by Robert Bradshaw's avatar Robert Bradshaw

More gdb test guards.

parent 0d89c84c
...@@ -645,7 +645,11 @@ class CythonUnitTestCase(CythonCompileTestCase): ...@@ -645,7 +645,11 @@ class CythonUnitTestCase(CythonCompileTestCase):
pass pass
include_debugger = sys.version_info[:2] > (2, 5) try:
import gdb
include_debugger = sys.version_info[:2] > (2, 5)
except:
include_debugger = False
def collect_unittests(path, module_prefix, suite, selectors): def collect_unittests(path, module_prefix, suite, selectors):
def file_matches(filename): def file_matches(filename):
...@@ -703,26 +707,27 @@ def collect_doctests(path, module_prefix, suite, selectors): ...@@ -703,26 +707,27 @@ def collect_doctests(path, module_prefix, suite, selectors):
filename in blacklist) filename in blacklist)
import doctest, types import doctest, types
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
parentname = os.path.split(dirpath)[-1] for dir in list(dirnames):
if package_matches(parentname): if not package_matches(dir):
for f in filenames: dirnames.remove(dir)
if file_matches(f): for f in filenames:
if not f.endswith('.py'): continue if file_matches(f):
filepath = os.path.join(dirpath, f) if not f.endswith('.py'): continue
if os.path.getsize(filepath) == 0: continue filepath = os.path.join(dirpath, f)
if 'no doctest' in open(filepath).next(): continue if os.path.getsize(filepath) == 0: continue
filepath = filepath[:-len(".py")] if 'no doctest' in open(filepath).next(): continue
modulename = module_prefix + filepath[len(path)+1:].replace(os.path.sep, '.') filepath = filepath[:-len(".py")]
if not [ 1 for match in selectors if match(modulename) ]: modulename = module_prefix + filepath[len(path)+1:].replace(os.path.sep, '.')
continue if not [ 1 for match in selectors if match(modulename) ]:
module = __import__(modulename) continue
for x in modulename.split('.')[1:]: module = __import__(modulename)
module = getattr(module, x) for x in modulename.split('.')[1:]:
if hasattr(module, "__doc__") or hasattr(module, "__test__"): module = getattr(module, x)
try: if hasattr(module, "__doc__") or hasattr(module, "__test__"):
suite.addTest(doctest.DocTestSuite(module)) try:
except ValueError: # no tests suite.addTest(doctest.DocTestSuite(module))
pass except ValueError: # no tests
pass
class EndToEndTest(unittest.TestCase): class EndToEndTest(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