1
# cython: autotestdict=True
2
# Directive defaults to True, but not when testing in Py3.4
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.cpdef_method (line 77) ; >>> add_log("cpdef class method")
14
MyCdefClass.method (line 74) ; >>> add_log("cdef class method")
15
MyClass.method (line 63) ; >>> add_log("class method")
16
mycpdeffunc (line 50) ; >>> add_log("cpdef")
17
myfunc (line 40) ; >>> add_log("def")
28
cdeffunc() # make sure it's being used
31
assert sorted(log) == sorted([u'cdef class', u'class'] + (
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__) + 7:
37
# Final per-function doctest executed
41
""">>> add_log("def")"""
42
x = lambda a:1 # no docstring here ...
44
def doc_without_test():
51
""">>> add_log("cpdef")"""
64
""">>> add_log("class method")"""
66
cdef class MyCdefClass:
70
>>> add_log("cdef class")
75
""">>> add_log("cdef class method")"""
77
cpdef cpdef_method(self):
78
""">>> add_log("cpdef class method")"""
80
cdef cdef_method(self):
81
""">>> add_log("cdef class cmethod")"""
85
Should not be included, as it can't be looked up with getattr
91
def __dealloc__(self):
93
Should not be included, as it can't be looked up with getattr
99
def __richcmp__(self, other, int op):
101
Should not be included, as it can't be looked up with getattr in Py 2
107
def __nonzero__(self):
109
Should not be included, as it can't be looked up with getattr in Py 3.1
117
Should not be included, as it can't be looked up with getattr in Py 3.1
119
>>> sys.version_info < (3, 4)
123
def __contains__(self, value):
125
Should not be included, as it can't be looked up with getattr in Py 3.1
127
>>> sys.version_info < (3, 4)
131
cdef class MyOtherCdefClass:
141
Should not be included, as it can't be looked up with getattr in Py 2