1
# cython: autotestdict=True, autotestdict.cdef=True
4
Tests autotestdict compiler directive.
6
Both module test and individual tests are run; finally,
7
all_tests_run() is executed which does final validation.
9
>>> items = list(__test__.items())
11
>>> for key, value in items:
12
... print('%s ; %s' % (key, value))
13
MyCdefClass.cdef_method (line 78) ; >>> add_log("cdef class cmethod")
14
MyCdefClass.cpdef_method (line 75) ; >>> add_log("cpdef class method")
15
MyCdefClass.method (line 72) ; >>> add_log("cdef class method")
16
MyClass.method (line 61) ; >>> add_log("class method")
17
cdeffunc (line 25) ; >>> add_log("cdef")
18
mycpdeffunc (line 48) ; >>> add_log("cpdef")
19
myfunc (line 39) ; >>> add_log("def")
26
""">>> add_log("cdef")"""
27
cdeffunc() # make sure it's being used
30
assert sorted(log) == sorted([u'cdef', u'cdef class', u'cdef class cmethod', u'class'] + (
31
2 * [u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'])), sorted(log)
34
log.append(unicode(s))
35
if len(log) == len(__test__) + 7:
36
# Final per-function doctest executed
40
""">>> add_log("def")"""
42
def doc_without_test():
49
""">>> add_log("cpdef")"""
62
""">>> add_log("class method")"""
64
cdef class MyCdefClass:
68
>>> add_log("cdef class")
73
""">>> add_log("cdef class method")"""
75
cpdef cpdef_method(self):
76
""">>> add_log("cpdef class method")"""
78
cdef cdef_method(self):
79
""">>> add_log("cdef class cmethod")"""
83
Should not be included, as it can't be looked up with getattr
89
def __dealloc__(self):
91
Should not be included, as it can't be looked up with getattr
97
def __richcmp__(self, other, int op):
99
Should not be included, as it can't be looked up with getattr in Py 2
105
def __nonzero__(self):
107
Should not be included, as it can't be looked up with getattr in Py 3.1
115
Should not be included, as it can't be looked up with getattr in Py 3.1
117
>>> sys.version_info < (3, 4)
121
def __contains__(self, value):
123
Should not be included, as it can't be looked up with getattr in Py 3.1
125
>>> sys.version_info < (3, 4)
129
cdef class MyOtherCdefClass:
139
Should not be included, as it can't be looked up with getattr in Py 2