From: Stefan Behnel Date: Tue, 2 Nov 2010 11:42:31 +0000 (+0100) Subject: reverted support for cdef functions in __test__ dict: increases module size and init... X-Git-Tag: 0.14.alpha0~266 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9dd53a87461af5691e9efceff38e0812c779f387;p=cython.git reverted support for cdef functions in __test__ dict: increases module size and init code but rarely helps --- diff --git a/Cython/Compiler/AnalysedTreeTransforms.py b/Cython/Compiler/AnalysedTreeTransforms.py index bb2996fd..69667abf 100644 --- a/Cython/Compiler/AnalysedTreeTransforms.py +++ b/Cython/Compiler/AnalysedTreeTransforms.py @@ -59,15 +59,16 @@ class AutoTestDictTransform(ScopeTrackingTransform): def visit_FuncDefNode(self, node): if not node.doc: return node + if isinstance(node, CFuncDefNode) and not node.py_func: + # skip non-cpdef cdef functions + return node + pos = self.testspos if self.scope_type == 'module': path = node.entry.name elif self.scope_type in ('pyclass', 'cclass'): if isinstance(node, CFuncDefNode): - if node.py_func is not None: - name = node.py_func.name - else: - name = node.entry.name + name = node.py_func.name else: name = node.name if self.scope_type == 'cclass' and name in self.blacklist: diff --git a/tests/run/autotestdict.pyx b/tests/run/autotestdict.pyx index eb3744ed..0e3bc09e 100644 --- a/tests/run/autotestdict.pyx +++ b/tests/run/autotestdict.pyx @@ -12,25 +12,28 @@ 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.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") -cdeffunc (line 28) ; >>> add_log("cdef") -doc_without_test (line 44) ; Some docs -mycpdeffunc (line 50) ; >>> add_log("cpdef") -myfunc (line 41) ; >>> add_log("def") +MyCdefClass.cpdef_method (line 79) ; >>> add_log("cpdef class method") +MyCdefClass.method (line 76) ; >>> add_log("cdef class method") +MyClass.method (line 65) ; >>> add_log("class method") +doc_without_test (line 47) ; Some docs +mycpdeffunc (line 53) ; >>> add_log("cpdef") +myfunc (line 44) ; >>> add_log("def") """ log = [] cdef cdeffunc(): - """>>> add_log("cdef")""" + """ + Please don't include me! + + >>> True + False + """ def all_tests_run(): log.sort() - assert log == [u'cdef', u'cdef class', u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'], log + assert log == [u'cdef class', u'cdef class method', u'class method', u'cpdef', u'cpdef class method', u'def'], log def add_log(s): log.append(unicode(s)) @@ -76,9 +79,6 @@ cdef class MyCdefClass: cpdef cpdef_method(self): """>>> add_log("cpdef class method")""" - cdef cdef_method(self): - """>>> add_log("cdef class method")""" - def __cinit__(self): """ Should not be included, as it can't be looked up with getattr