summaryrefslogtreecommitdiff
path: root/tests/compile
diff options
context:
space:
mode:
authorda-woods <dw-git@d-woods.co.uk>2020-05-19 09:12:56 +0100
committerGitHub <noreply@github.com>2020-05-19 10:12:56 +0200
commit6d83a741e0d083f07be87aa52970fa2fadf001b6 (patch)
tree4d661e6b8d8c2ee7ab9fa8d131a6bf779e76c4c7 /tests/compile
parent2ffcb6a0a9b5145ad985abd23527204477f21788 (diff)
downloadcython-6d83a741e0d083f07be87aa52970fa2fadf001b6.tar.gz
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.
Diffstat (limited to 'tests/compile')
-rw-r--r--tests/compile/tree_assertions.pyx20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/compile/tree_assertions.pyx b/tests/compile/tree_assertions.pyx
new file mode 100644
index 000000000..e311bfd25
--- /dev/null
+++ b/tests/compile/tree_assertions.pyx
@@ -0,0 +1,20 @@
+# 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..