From 3be21c3b15cde754a9282c0df1ffb9f72bb92ff3 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Thu, 2 Dec 2010 12:14:12 +0100 Subject: [PATCH] Skip debugger tests for pre-2.5 python versions and make them 2.5 compatible --- .../Compiler/Tests/TestParseTreeTransforms.py | 17 +++++++++++++---- Cython/Debugger/Tests/TestLibCython.py | 2 ++ runtests.py | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/Tests/TestParseTreeTransforms.py b/Cython/Compiler/Tests/TestParseTreeTransforms.py index e6522d94..6ea60a1a 100644 --- a/Cython/Compiler/Tests/TestParseTreeTransforms.py +++ b/Cython/Compiler/Tests/TestParseTreeTransforms.py @@ -1,11 +1,10 @@ import os -from Cython.Debugger import DebugWriter from Cython.Compiler import CmdLine from Cython.TestUtils import TransformTest from Cython.Compiler.ParseTreeTransforms import * from Cython.Compiler.Nodes import * -from Cython.Debugger.Tests import TestLibCython + class TestNormalizeTree(TransformTest): def test_parserbehaviour_is_what_we_coded_for(self): @@ -144,8 +143,15 @@ class TestWithTransform(object): # (TransformTest): # Disabled! """, t) - -class TestDebugTransform(TestLibCython.DebuggerTestCase): + +if sys.version_info[:2] > (2, 4): + from Cython.Debugger import DebugWriter + from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase +else: + # skip test, don't let it inherit unittest.TestCase + DebuggerTestCase = object + +class TestDebugTransform(DebuggerTestCase): def elem_hasattrs(self, elem, attrs): # we shall supporteth python 2.3 ! @@ -209,6 +215,9 @@ class TestDebugTransform(TestLibCython.DebuggerTestCase): raise + + + if __name__ == "__main__": import unittest unittest.main() diff --git a/Cython/Debugger/Tests/TestLibCython.py b/Cython/Debugger/Tests/TestLibCython.py index 4e4d3ced..082657a5 100644 --- a/Cython/Debugger/Tests/TestLibCython.py +++ b/Cython/Debugger/Tests/TestLibCython.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import os import re import sys diff --git a/runtests.py b/runtests.py index 53833a00..1fa0df42 100644 --- a/runtests.py +++ b/runtests.py @@ -624,6 +624,8 @@ class CythonUnitTestCase(CythonCompileTestCase): except Exception: pass +include_debugger = sys.version_info[:2] > (2, 4) + def collect_unittests(path, module_prefix, suite, selectors): def file_matches(filename): return filename.startswith("Test") and filename.endswith(".py") @@ -632,8 +634,12 @@ def collect_unittests(path, module_prefix, suite, selectors): return dirname == "Tests" loader = unittest.TestLoader() - - skipped_dirs = [] + + if include_debugger: + skipped_dirs = [] + else: + cython_dir = os.path.dirname(os.path.abspath(__file__)) + skipped_dirs = [os.path.join(cython_dir, 'Cython', 'Debugger')] for dirpath, dirnames, filenames in os.walk(path): if dirpath != path and "__init__.py" not in filenames: @@ -658,12 +664,17 @@ def collect_unittests(path, module_prefix, suite, selectors): module = getattr(module, x) suite.addTests([loader.loadTestsFromModule(module)]) + + def collect_doctests(path, module_prefix, suite, selectors): def package_matches(dirname): + if dirname == 'Debugger' and not include_debugger: + return False return dirname not in ("Mac", "Distutils", "Plex") def file_matches(filename): filename, ext = os.path.splitext(filename) - blacklist = ('libcython', 'libpython', 'test_libcython_in_gdb') + blacklist = ['libcython', 'libpython', 'test_libcython_in_gdb', + 'TestLibCython'] return (ext == '.py' and not '~' in filename and not '#' in filename and not -- 2.26.2