Commit 4d5dfea1 authored by Stefan Behnel's avatar Stefan Behnel

disable autotestdict when testing under Py3.4 and adapt autotestdict tests to...

disable autotestdict when testing under Py3.4 and adapt autotestdict tests to make up for its smarter docstring lookup
parent cfa644cc
...@@ -551,6 +551,8 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -551,6 +551,8 @@ class CythonCompileTestCase(unittest.TestCase):
'error_on_uninitialized') ] 'error_on_uninitialized') ]
self._saved_default_directives = Options.directive_defaults.items() self._saved_default_directives = Options.directive_defaults.items()
Options.warning_errors = self.warning_errors Options.warning_errors = self.warning_errors
if sys.version_info >= (3, 4):
Options.directive_defaults['autotestdict'] = False
if not os.path.exists(self.workdir): if not os.path.exists(self.workdir):
os.makedirs(self.workdir) os.makedirs(self.workdir)
......
# Directive defaults to True # cython: autotestdict=True
# Directive defaults to True, but not when testing in Py3.4
""" """
Tests autotestdict compiler directive. Tests autotestdict compiler directive.
...@@ -15,9 +15,9 @@ MyCdefClass.method (line 74) ; >>> add_log("cdef class method") ...@@ -15,9 +15,9 @@ MyCdefClass.method (line 74) ; >>> add_log("cdef class method")
MyClass.method (line 63) ; >>> add_log("class method") MyClass.method (line 63) ; >>> add_log("class method")
mycpdeffunc (line 50) ; >>> add_log("cpdef") mycpdeffunc (line 50) ; >>> add_log("cpdef")
myfunc (line 40) ; >>> add_log("def") myfunc (line 40) ; >>> add_log("def")
""" """
import sys
log = [] log = []
cdef cdeffunc(): cdef cdeffunc():
...@@ -28,12 +28,12 @@ cdef cdeffunc(): ...@@ -28,12 +28,12 @@ cdef cdeffunc():
cdeffunc() # make sure it's being used cdeffunc() # make sure it's being used
def all_tests_run(): def all_tests_run():
log.sort() assert sorted(log) == sorted([u'cdef class', u'class'] + (
assert log == [u'cdef class', u'cdef class method', u'class', u'class method', u'cpdef', u'cpdef class method', u'def'], log (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): def add_log(s):
log.append(unicode(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 # Final per-function doctest executed
all_tests_run() all_tests_run()
...@@ -78,7 +78,7 @@ cdef class MyCdefClass: ...@@ -78,7 +78,7 @@ cdef class MyCdefClass:
""">>> add_log("cpdef class method")""" """>>> add_log("cpdef class method")"""
cdef cdef_method(self): cdef cdef_method(self):
""">>> add_log("cdef class method")""" """>>> add_log("cdef class cmethod")"""
def __cinit__(self): def __cinit__(self):
""" """
...@@ -116,7 +116,7 @@ cdef class MyCdefClass: ...@@ -116,7 +116,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
...@@ -124,7 +124,7 @@ cdef class MyCdefClass: ...@@ -124,7 +124,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
......
# cython: autotestdict.all=True # cython: autotestdict=True, autotestdict.all=True
""" """
Tests autotestdict compiler directive. Tests autotestdict compiler directive.
...@@ -10,7 +10,7 @@ all_tests_run() is executed which does final validation. ...@@ -10,7 +10,7 @@ all_tests_run() is executed which does final validation.
>>> items.sort() >>> items.sort()
>>> for key, value in items: >>> for key, value in items:
... print('%s ; %s' % (key, value)) ... 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.cpdef_method (line 76) ; >>> add_log("cpdef class method")
MyCdefClass.method (line 73) ; >>> add_log("cdef class method") MyCdefClass.method (line 73) ; >>> add_log("cdef class method")
MyClass.method (line 62) ; >>> add_log("class method") MyClass.method (line 62) ; >>> add_log("class method")
...@@ -18,9 +18,9 @@ cdeffunc (line 26) ; >>> add_log("cdef") ...@@ -18,9 +18,9 @@ cdeffunc (line 26) ; >>> add_log("cdef")
doc_without_test (line 43) ; Some docs doc_without_test (line 43) ; Some docs
mycpdeffunc (line 49) ; >>> add_log("cpdef") mycpdeffunc (line 49) ; >>> add_log("cpdef")
myfunc (line 40) ; >>> add_log("def") myfunc (line 40) ; >>> add_log("def")
""" """
import sys
log = [] log = []
cdef cdeffunc(): cdef cdeffunc():
...@@ -28,12 +28,12 @@ cdef cdeffunc(): ...@@ -28,12 +28,12 @@ cdef cdeffunc():
cdeffunc() # make sure it's being used cdeffunc() # make sure it's being used
def all_tests_run(): def all_tests_run():
log.sort() assert sorted(log) == sorted([u'cdef', u'cdef class', u'class', u'cdef class cmethod'] + (
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 (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): def add_log(s):
log.append(unicode(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 # Final per-function doctest executed
all_tests_run() all_tests_run()
...@@ -77,7 +77,7 @@ cdef class MyCdefClass: ...@@ -77,7 +77,7 @@ cdef class MyCdefClass:
""">>> add_log("cpdef class method")""" """>>> add_log("cpdef class method")"""
cdef cdef_method(self): cdef cdef_method(self):
""">>> add_log("cdef class method")""" """>>> add_log("cdef class cmethod")"""
def __cinit__(self): def __cinit__(self):
""" """
...@@ -115,7 +115,7 @@ cdef class MyCdefClass: ...@@ -115,7 +115,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
...@@ -123,7 +123,7 @@ cdef class MyCdefClass: ...@@ -123,7 +123,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
......
# cython: autotestdict.cdef=True # cython: autotestdict=True, autotestdict.cdef=True
""" """
Tests autotestdict compiler directive. Tests autotestdict compiler directive.
...@@ -10,16 +10,16 @@ all_tests_run() is executed which does final validation. ...@@ -10,16 +10,16 @@ all_tests_run() is executed which does final validation.
>>> items.sort() >>> items.sort()
>>> for key, value in items: >>> for key, value in items:
... print('%s ; %s' % (key, value)) ... 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.cpdef_method (line 75) ; >>> add_log("cpdef class method")
MyCdefClass.method (line 72) ; >>> add_log("cdef class method") MyCdefClass.method (line 72) ; >>> add_log("cdef class method")
MyClass.method (line 61) ; >>> add_log("class method") MyClass.method (line 61) ; >>> add_log("class method")
cdeffunc (line 25) ; >>> add_log("cdef") cdeffunc (line 25) ; >>> add_log("cdef")
mycpdeffunc (line 48) ; >>> add_log("cpdef") mycpdeffunc (line 48) ; >>> add_log("cpdef")
myfunc (line 39) ; >>> add_log("def") myfunc (line 39) ; >>> add_log("def")
""" """
import sys
log = [] log = []
cdef cdeffunc(): cdef cdeffunc():
...@@ -27,12 +27,12 @@ cdef cdeffunc(): ...@@ -27,12 +27,12 @@ cdef cdeffunc():
cdeffunc() # make sure it's being used cdeffunc() # make sure it's being used
def all_tests_run(): def all_tests_run():
log.sort() assert sorted(log) == sorted([u'cdef', u'cdef class', u'cdef class cmethod', u'class'] + (
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 ((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): def add_log(s):
log.append(unicode(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 # Final per-function doctest executed
all_tests_run() all_tests_run()
...@@ -76,7 +76,7 @@ cdef class MyCdefClass: ...@@ -76,7 +76,7 @@ cdef class MyCdefClass:
""">>> add_log("cpdef class method")""" """>>> add_log("cpdef class method")"""
cdef cdef_method(self): cdef cdef_method(self):
""">>> add_log("cdef class method")""" """>>> add_log("cdef class cmethod")"""
def __cinit__(self): def __cinit__(self):
""" """
...@@ -114,7 +114,7 @@ cdef class MyCdefClass: ...@@ -114,7 +114,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
...@@ -122,7 +122,7 @@ cdef class MyCdefClass: ...@@ -122,7 +122,7 @@ cdef class MyCdefClass:
""" """
Should not be included, as it can't be looked up with getattr in Py 3.1 Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True >>> sys.version_info < (3, 4)
False False
""" """
......
...@@ -10,10 +10,11 @@ If this doesn't work, then the function doctest should fail. ...@@ -10,10 +10,11 @@ If this doesn't work, then the function doctest should fail.
True True
""" """
import sys
def func(): def func():
""" """
>>> True >>> sys.version_info < (3, 4)
False False
""" """
......
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