from Cython.Compiler.Visitor import VisitorTransform, ScopeTrackingTransform, TreeVisitor
-from Nodes import StatListNode, SingleAssignmentNode
+from Nodes import StatListNode, SingleAssignmentNode, CFuncDefNode
from ExprNodes import (DictNode, DictItemNode, NameNode, UnicodeNode, NoneNode,
ExprNode, AttributeNode, ModuleRefNode, DocstringRefNode)
from PyrexTypes import py_object_type
def visit_FuncDefNode(self, node):
if node.doc:
+ if isinstance(node, CFuncDefNode) and not node.py_func:
+ # skip non-cpdef cdef functions
+ return node
+
pos = self.testspos
if self.scope_type == 'module':
parent = ModuleRefNode(pos)
is_py_attr=True,
is_temp=True)
name = "%s.%s" % (clsname, node.entry.name)
+ else:
+ assert False
getfunc = AttributeNode(pos, obj=parent,
attribute=node.entry.name,
type=py_object_type,
-#cython: doctesthack=True
+# Directive defaults to True
"""
Tests doctesthack compiler directive.
>>> items.sort()
>>> for key, value in items:
... print key, ';', value
-MyCdefClass.method (line 67) ; >>> add_log("cdef class method")
-MyClass.method (line 57) ; >>> add_log("class method")
-doc_without_test (line 39) ; Some docs
-mycpdeffunc (line 45) ; >>> add_log("cpdef")
-myfunc (line 36) ; >>> add_log("def")
+MyCdefClass.method (line 75) ; >>> 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():
+ """
+ Please don't include me!
+
+ >>> True
+ False
+ """
+
def all_tests_run():
log.sort()
assert log == [u'cdef class method', u'class method', u'cpdef', u'def'], log