'doctesthack': False,
# test support
- 'testAssertPathExists' : [],
- 'testFailIfPathExists' : [],
+ 'test_assert_path_exists' : [],
+ 'test_fail_if_path_exists' : [],
}
# Override types possibilities above, if needed
option_scopes = { # defaults to available everywhere
# 'module', 'function', 'class', 'with statement'
'doctesthack' : ('module',),
- 'testAssertPathExists' : ('function',),
- 'testFailIfPathExists' : ('function',),
+ 'test_assert_path_exists' : ('function',),
+ 'test_fail_if_path_exists' : ('function',),
}
def parse_option_value(name, value):
def visit_CompilerDirectivesNode(self, node):
directives = node.directives
- if 'testAssertPathExists' in directives:
- for path in directives['testAssertPathExists']:
+ if 'test_assert_path_exists' in directives:
+ for path in directives['test_assert_path_exists']:
if TreePath.find_first(node, path) is None:
Errors.error(
node.pos,
- "Expected path '%s' not found in result tree of node %r" % (
- path, node.body))
- if 'testFailIfPathExists' in directives:
- for path in directives['testFailIfPathExists']:
+ "Expected path '%s' not found in result tree" % path)
+ if 'test_fail_if_path_exists' in directives:
+ for path in directives['test_fail_if_path_exists']:
if TreePath.find_first(node, path) is not None:
Errors.error(
node.pos,
- "Unexpected path '%s' found in result tree of node %r" % (
- path, node.body))
+ "Unexpected path '%s' found in result tree" % path)
self.visitchildren(node)
return node
--- /dev/null
+
+cimport cython
+
+@cython.test_fail_if_path_exists("//SimpleCallNode",
+ "//NameNode")
+@cython.test_assert_path_exists("//ComprehensionNode",
+ "//ComprehensionNode//FuncDefNode")
+def test():
+ object()
+
+
+_ERRORS = u"""
+8:0: Expected path '//ComprehensionNode' not found in result tree
+8:0: Expected path '//ComprehensionNode//FuncDefNode' not found in result tree
+8:0: Unexpected path '//NameNode' found in result tree
+8:0: Unexpected path '//SimpleCallNode' found in result tree
+"""
for x in range(5)
if x % 2 == 0 }
-@cython.testFailIfPathExists("//ComprehensionNode//ComprehensionAppendNode",
- "//SimpleCallNode//ComprehensionNode")
-@cython.testAssertPathExists("//ComprehensionNode",
- "//ComprehensionNode//DictComprehensionAppendNode")
+@cython.test_fail_if_path_exists(
+ "//ComprehensionNode//ComprehensionAppendNode",
+ "//SimpleCallNode//ComprehensionNode")
+@cython.test_assert_path_exists(
+ "//ComprehensionNode",
+ "//ComprehensionNode//DictComprehensionAppendNode")
def smoketest_list():
return dict([ (x+2,x*2)
for x in range(5)
cimport cython
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def go_py_enumerate():
for i,k in enumerate(range(1,5)):
print i, k
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def go_c_enumerate():
cdef int i,k
for i,k in enumerate(range(1,5)):
print i, k
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def go_c_enumerate_step():
cdef int i,k
for i,k in enumerate(range(1,7,2)):
print i, k
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def py_enumerate_dict(dict d):
cdef int i = 55
k = 99
print i, k
print u"::", i, k
-@cython.testFailIfPathExists("//SimpleCallNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode")
def py_enumerate_break(*t):
i,k = 55,99
for i,k in enumerate(t):
break
print u"::", i, k
-@cython.testFailIfPathExists("//SimpleCallNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode")
def py_enumerate_return(*t):
i,k = 55,99
for i,k in enumerate(t):
return
print u"::", i, k
-@cython.testFailIfPathExists("//SimpleCallNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode")
def py_enumerate_continue(*t):
i,k = 55,99
for i,k in enumerate(t):
continue
print u"::", i, k
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def empty_c_enumerate():
cdef int i = 55, k = 99
for i,k in enumerate(range(0)):
for t in enumerate(range(1,5)):
print t[0], t[1]
-@cython.testFailIfPathExists("//SimpleCallNode//NameNode[@name = 'enumerate']")
+@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def multi_enumerate():
for a,(b,(c,d)) in enumerate(enumerate(enumerate(range(1,5)))):
print a,b,c,d
-@cython.testFailIfPathExists("//SimpleCallNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode")
def multi_c_enumerate():
cdef int a,b,c,d
for a,(b,(c,d)) in enumerate(enumerate(enumerate(range(1,5)))):
cimport cython
-@cython.testAssertPathExists("//ForFromStatNode")
-@cython.testFailIfPathExists("//ForInStatNode")
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
def test_modify():
cdef int i, n = 5
for i in range(n):
print
return i,n
-@cython.testAssertPathExists("//ForFromStatNode")
-@cython.testFailIfPathExists("//ForInStatNode")
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
def test_fix():
cdef int i
for i in range(5):
print
return i
-@cython.testAssertPathExists("//ForFromStatNode")
-@cython.testFailIfPathExists("//ForInStatNode")
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
def test_break():
cdef int i, n = 5
for i in range(n):
print
return i,n
-@cython.testAssertPathExists("//ForFromStatNode")
-@cython.testFailIfPathExists("//ForInStatNode")
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
def test_return():
cdef int i, n = 5
for i in range(n):
for x in range(5)
if x % 2 == 0 }
-@cython.testFailIfPathExists("//SimpleCallNode//ComprehensionNode")
-@cython.testAssertPathExists("//ComprehensionNode",
- "//ComprehensionNode//ComprehensionAppendNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode//ComprehensionNode")
+@cython.test_assert_path_exists("//ComprehensionNode",
+ "//ComprehensionNode//ComprehensionAppendNode")
def smoketest_list():
return set([ x*2
for x in range(5)