Commit 6d83a741 authored by da-woods's avatar da-woods Committed by GitHub

Fixed "test_*_path_exists" + CompilerDirectivesNode (GH-3619)

When test_assert_path_exists or test_fail_if_path_exists
was used on a function containing a CompilerDirectivesNode
it was inherited by that CompilerDirectivesNode. Therefore
you got misleading test failures if the path was in the
function but not within that CompilerDirectivesNode.
parent 2ffcb6a0
......@@ -993,6 +993,10 @@ class InterpretCompilerDirectives(CythonTransform):
old_directives = self.directives
new_directives = dict(old_directives)
# test_assert_path_exists and test_fail_if_path_exists should not be inherited
# otherwise they can produce very misleading test failures
new_directives.pop('test_assert_path_exists', None)
new_directives.pop('test_fail_if_path_exists', None)
new_directives.update(directives)
if new_directives == old_directives:
......
# mode: compile
# This is a sort of meta test - to test the functionality of "test_assert_path_exists"
cimport cython
@cython.test_assert_path_exists("//ReturnStatNode")
def not_in_inner_compiler_directives():
# used to fail because ReturnStatNode wasn't in *this* CompilerDirectivesNode
with cython.boundscheck(False):
pass
return 1 # should pass
@cython.test_assert_path_exists("//ReturnStatNode")
def in_inner_compiler_directives():
# used to fail because ReturnStatNode wasn't in *this* CompilerDirectivesNode
with cython.boundscheck(False):
return 1
# it's hard to come up with a corresponding test for fail_if_path_exists..
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment