Skip debugger tests for pre-2.5 python versions and make them 2.5 compatible
authorMark Florisson <markflorisson88@gmail.com>
Thu, 2 Dec 2010 11:14:12 +0000 (12:14 +0100)
committerMark Florisson <markflorisson88@gmail.com>
Thu, 2 Dec 2010 11:14:12 +0000 (12:14 +0100)
Cython/Compiler/Tests/TestParseTreeTransforms.py
Cython/Debugger/Tests/TestLibCython.py
runtests.py

index e6522d94b62842e6c7d1a8415b3eb86004c07029..6ea60a1a3b63c0f09f645c47f389582362d11328 100644 (file)
@@ -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()
index 4e4d3ced444d6bd690a6416215a2c352c0fae334..082657a5f030b396c2ac85091f328460728c5941 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import with_statement
+
 import os
 import re
 import sys
index 53833a00d290fd6e896f53564acd8f4d0760af5b..1fa0df42ec00970a5739902125cf756c8e0f8ebf 100644 (file)
@@ -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