disable autotestdict when testing under Py3.4 and adapt autotestdict tests to make...
authorStefan Behnel <stefan_ml@behnel.de>
Fri, 29 Nov 2013 12:58:40 +0000 (13:58 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Fri, 29 Nov 2013 12:58:40 +0000 (13:58 +0100)
runtests.py
tests/run/autotestdict.pyx
tests/run/autotestdict_all.pyx
tests/run/autotestdict_cdef.pyx
tests/run/autotestdict_skip.pyx

index f131ee4..95a5b5a 100755 (executable)
@@ -551,6 +551,8 @@ class CythonCompileTestCase(unittest.TestCase):
                                              'error_on_uninitialized') ]
         self._saved_default_directives = Options.directive_defaults.items()
         Options.warning_errors = self.warning_errors
+        if sys.version_info >= (3, 4):
+            Options.directive_defaults['autotestdict'] = False
 
         if not os.path.exists(self.workdir):
             os.makedirs(self.workdir)
index 0824aff..32921f8 100644 (file)
@@ -1,5 +1,5 @@
-# Directive defaults to True
-
+# cython: autotestdict=True
+# Directive defaults to True, but not when testing in Py3.4
 """
 Tests autotestdict compiler directive.
 
@@ -15,9 +15,9 @@ MyCdefClass.method (line 74) ; >>> add_log("cdef class method")
 MyClass.method (line 63) ; >>> add_log("class method")
 mycpdeffunc (line 50) ; >>> add_log("cpdef")
 myfunc (line 40) ; >>> add_log("def")
-
 """
 
+import sys
 log = []
 
 cdef cdeffunc():
@@ -28,12 +28,12 @@ cdef cdeffunc():
 cdeffunc() # make sure it's being used
 
 def all_tests_run():
-    log.sort()
-    assert log == [u'cdef class', u'cdef class method', u'class', u'class method', u'cpdef', u'cpdef class method', u'def'], log
+    assert sorted(log) == sorted([u'cdef class', u'class'] + (
+        (1 if sys.version_info < (3, 4) else 2) * [u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'])), sorted(log)
 
 def add_log(s):
     log.append(unicode(s))
-    if len(log) == len(__test__) + 2:
+    if len(log) == len(__test__) + (2 if sys.version_info < (3, 4) else 7):
         # Final per-function doctest executed
         all_tests_run()
 
@@ -78,7 +78,7 @@ cdef class MyCdefClass:
         """>>> add_log("cpdef class method")"""
 
     cdef cdef_method(self):
-        """>>> add_log("cdef class method")"""
+        """>>> add_log("cdef class cmethod")"""
 
     def __cinit__(self):
         """
@@ -116,7 +116,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
@@ -124,7 +124,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
index 624a12b..b93e7db 100644 (file)
@@ -1,4 +1,4 @@
-# cython: autotestdict.all=True
+# cython: autotestdict=True, autotestdict.all=True
 
 """
 Tests autotestdict compiler directive.
@@ -10,7 +10,7 @@ all_tests_run() is executed which does final validation.
 >>> items.sort()
 >>> for key, value in items:
 ...     print('%s ; %s' % (key, value))
-MyCdefClass.cdef_method (line 79) ; >>> add_log("cdef class method")
+MyCdefClass.cdef_method (line 79) ; >>> add_log("cdef class cmethod")
 MyCdefClass.cpdef_method (line 76) ; >>> add_log("cpdef class method")
 MyCdefClass.method (line 73) ; >>> add_log("cdef class method")
 MyClass.method (line 62) ; >>> add_log("class method")
@@ -18,9 +18,9 @@ cdeffunc (line 26) ; >>> add_log("cdef")
 doc_without_test (line 43) ; Some docs
 mycpdeffunc (line 49) ; >>> add_log("cpdef")
 myfunc (line 40) ; >>> add_log("def")
-
 """
 
+import sys
 log = []
 
 cdef cdeffunc():
@@ -28,12 +28,12 @@ cdef cdeffunc():
 cdeffunc() # make sure it's being used
 
 def all_tests_run():
-    log.sort()
-    assert log == [u'cdef', u'cdef class', u'cdef class method', u'class', u'class method', u'cpdef', u'cpdef class method', u'def'], log
+    assert sorted(log) == sorted([u'cdef', u'cdef class', u'class', u'cdef class cmethod'] + (
+        (1 if sys.version_info < (3, 4) else 2) * [u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'])), sorted(log)
 
 def add_log(s):
     log.append(unicode(s))
-    if len(log) == len(__test__):
+    if len(log) == len(__test__) + (1 if sys.version_info < (3, 4) else 6):
         # Final per-function doctest executed
         all_tests_run()
 
@@ -77,7 +77,7 @@ cdef class MyCdefClass:
         """>>> add_log("cpdef class method")"""
 
     cdef cdef_method(self):
-        """>>> add_log("cdef class method")"""
+        """>>> add_log("cdef class cmethod")"""
 
     def __cinit__(self):
         """
@@ -115,7 +115,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
@@ -123,7 +123,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
index c490987..1102d70 100644 (file)
@@ -1,4 +1,4 @@
-# cython: autotestdict.cdef=True
+# cython: autotestdict=True, autotestdict.cdef=True
 
 """
 Tests autotestdict compiler directive.
@@ -10,16 +10,16 @@ all_tests_run() is executed which does final validation.
 >>> items.sort()
 >>> for key, value in items:
 ...     print('%s ; %s' % (key, value))
-MyCdefClass.cdef_method (line 78) ; >>> add_log("cdef class method")
+MyCdefClass.cdef_method (line 78) ; >>> add_log("cdef class cmethod")
 MyCdefClass.cpdef_method (line 75) ; >>> add_log("cpdef class method")
 MyCdefClass.method (line 72) ; >>> add_log("cdef class method")
 MyClass.method (line 61) ; >>> add_log("class method")
 cdeffunc (line 25) ; >>> add_log("cdef")
 mycpdeffunc (line 48) ; >>> add_log("cpdef")
 myfunc (line 39) ; >>> add_log("def")
-
 """
 
+import sys
 log = []
 
 cdef cdeffunc():
@@ -27,12 +27,12 @@ cdef cdeffunc():
 cdeffunc() # make sure it's being used
 
 def all_tests_run():
-    log.sort()
-    assert log == [u'cdef', u'cdef class', u'cdef class method', u'class', u'class method', u'cpdef', u'cpdef class method', u'def'], log
+    assert sorted(log) == sorted([u'cdef', u'cdef class', u'cdef class cmethod', u'class'] + (
+        ((1 if sys.version_info < (3, 4) else 2) * [u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def']))), sorted(log)
 
 def add_log(s):
     log.append(unicode(s))
-    if len(log) == len(__test__) + 1:
+    if len(log) == len(__test__) + (2 if sys.version_info < (3, 4) else 7):
         # Final per-function doctest executed
         all_tests_run()
 
@@ -76,7 +76,7 @@ cdef class MyCdefClass:
         """>>> add_log("cpdef class method")"""
 
     cdef cdef_method(self):
-        """>>> add_log("cdef class method")"""
+        """>>> add_log("cdef class cmethod")"""
 
     def __cinit__(self):
         """
@@ -114,7 +114,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
@@ -122,7 +122,7 @@ cdef class MyCdefClass:
         """
         Should not be included, as it can't be looked up with getattr in Py 3.1
 
-        >>> True
+        >>> sys.version_info < (3, 4)
         False
         """
 
index 3ea6d82..dd1c652 100644 (file)
@@ -10,10 +10,11 @@ If this doesn't work, then the function doctest should fail.
 True
 """
 
+import sys
 
 def func():
     """
-    >>> True
+    >>> sys.version_info < (3, 4)
     False
     """