1
# cython: autotestdict=True, autotestdict.all=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 79) ; >>> add_log("cdef class cmethod")
14
MyCdefClass.cpdef_method (line 76) ; >>> add_log("cpdef class method")
15
MyCdefClass.method (line 73) ; >>> add_log("cdef class method")
16
MyClass.method (line 62) ; >>> add_log("class method")
17
cdeffunc (line 26) ; >>> add_log("cdef")
18
doc_without_test (line 43) ; Some docs
19
mycpdeffunc (line 49) ; >>> add_log("cpdef")
20
myfunc (line 40) ; >>> add_log("def")
27
""">>> add_log("cdef")"""
28
cdeffunc() # make sure it's being used
31
assert sorted(log) == sorted([u'cdef', u'cdef class', u'class', u'cdef class cmethod'] + (
32
2 * [u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'])), sorted(log)
35
log.append(unicode(s))
36
if len(log) == len(__test__) + 6:
37
# Final per-function doctest executed
41
""">>> add_log("def")"""
43
def doc_without_test():
50
""">>> add_log("cpdef")"""
63
""">>> add_log("class method")"""
65
cdef class MyCdefClass:
69
>>> add_log("cdef class")
74
""">>> add_log("cdef class method")"""
76
cpdef cpdef_method(self):
77
""">>> add_log("cpdef class method")"""
79
cdef cdef_method(self):
80
""">>> add_log("cdef class cmethod")"""
84
Should not be included, as it can't be looked up with getattr
90
def __dealloc__(self):
92
Should not be included, as it can't be looked up with getattr
98
def __richcmp__(self, other, int op):
100
Should not be included, as it can't be looked up with getattr in Py 2
106
def __nonzero__(self):
108
Should not be included, as it can't be looked up with getattr in Py 3.1
116
Should not be included, as it can't be looked up with getattr in Py 3.1
118
>>> sys.version_info < (3, 4)
122
def __contains__(self, value):
124
Should not be included, as it can't be looked up with getattr in Py 3.1
126
>>> sys.version_info < (3, 4)
130
cdef class MyOtherCdefClass:
140
Should not be included, as it can't be looked up with getattr in Py 2