Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
3f00253b
Commit
3f00253b
authored
Oct 05, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix doctesthack for cdef functions
parent
4c11531e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
Cython/Compiler/AnalysedTreeTransforms.py
Cython/Compiler/AnalysedTreeTransforms.py
+7
-1
tests/run/doctesthack.pyx
tests/run/doctesthack.pyx
+14
-6
No files found.
Cython/Compiler/AnalysedTreeTransforms.py
View file @
3f00253b
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
...
...
@@ -53,6 +53,10 @@ class DoctestHackTransform(ScopeTrackingTransform):
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
)
...
...
@@ -69,6 +73,8 @@ class DoctestHackTransform(ScopeTrackingTransform):
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
,
...
...
tests/run/doctesthack.pyx
View file @
3f00253b
#
cython: doctesthack=
True
#
Directive defaults to
True
"""
Tests doctesthack compiler directive.
...
...
@@ -12,17 +12,25 @@ all_tests_run() is executed which does final validation.
>>> 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
cdef
func
():
"""
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment