1# mode: run 2 3cimport cython 4 5def f(a, b, int i): 6 """ 7 >>> f(1, 2, 1) 8 >>> f(0, 2, 1) 9 Traceback (most recent call last): 10 AssertionError 11 >>> f(1, -1, 1) 12 Traceback (most recent call last): 13 AssertionError 14 >>> f(1, 2, 0) 15 Traceback (most recent call last): 16 AssertionError 17 """ 18 assert a 19 assert a+b 20 assert i 21 22 23@cython.test_assert_path_exists( 24 '//AssertStatNode', 25 '//AssertStatNode//TupleNode') 26def g(a, b): 27 """ 28 >>> g(1, "works") 29 >>> g(0, "fails") 30 Traceback (most recent call last): 31 AssertionError: fails 32 >>> g(0, (1, 2)) 33 Traceback (most recent call last): 34 AssertionError: (1, 2) 35 """ 36 assert a, b 37 38 39@cython.test_assert_path_exists( 40 '//AssertStatNode', 41 '//AssertStatNode//TupleNode') 42def g(a, b): 43 """ 44 >>> g(1, "works") 45 >>> g(0, "fails") 46 Traceback (most recent call last): 47 AssertionError: fails 48 >>> g(0, (1, 2)) 49 Traceback (most recent call last): 50 AssertionError: (1, 2) 51 """ 52 assert a, b 53 54 55@cython.test_assert_path_exists( 56 '//AssertStatNode', 57 '//AssertStatNode//TupleNode', 58 '//AssertStatNode//TupleNode//TupleNode') 59def assert_with_tuple_arg(a): 60 """ 61 >>> assert_with_tuple_arg(True) 62 >>> assert_with_tuple_arg(False) 63 Traceback (most recent call last): 64 AssertionError: (1, 2) 65 """ 66 assert a, (1, 2) 67 68 69@cython.test_assert_path_exists( 70 '//AssertStatNode') 71@cython.test_fail_if_path_exists( 72 '//AssertStatNode//TupleNode') 73def assert_with_str_arg(a): 74 """ 75 >>> assert_with_str_arg(True) 76 >>> assert_with_str_arg(False) 77 Traceback (most recent call last): 78 AssertionError: abc 79 """ 80 assert a, 'abc' 81