diff options
Diffstat (limited to 'tests/run/locals.pyx')
-rw-r--r-- | tests/run/locals.pyx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/run/locals.pyx b/tests/run/locals.pyx index f343fe1cb..2e7c0a961 100644 --- a/tests/run/locals.pyx +++ b/tests/run/locals.pyx @@ -5,6 +5,8 @@ def get_locals(x, *args, **kwds): """ >>> sorted( get_locals(1,2,3, k=5).items() ) [('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)] + >>> sorted( get_locals(1).items() ) # args and kwds should *always* be present even if not passed + [('args', ()), ('kwds', {}), ('x', 1), ('y', 'hi'), ('z', 5)] """ cdef int z = 5 y = "hi" @@ -14,6 +16,8 @@ def get_vars(x, *args, **kwds): """ >>> sorted( get_vars(1,2,3, k=5).items() ) [('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)] + >>> sorted( get_vars(1).items() ) + [('args', ()), ('kwds', {}), ('x', 1), ('y', 'hi'), ('z', 5)] """ cdef int z = 5 y = "hi" @@ -23,6 +27,8 @@ def get_dir(x, *args, **kwds): """ >>> sorted( get_dir(1,2,3, k=5) ) ['args', 'kwds', 'x', 'y', 'z'] + >>> sorted( get_dir(1) ) + ['args', 'kwds', 'x', 'y', 'z'] """ cdef int z = 5 y = "hi" @@ -36,6 +42,8 @@ def in_locals(x, *args, **kwds): True >>> in_locals('X') False + >>> in_locals('kwds') + True """ cdef int z = 5 y = "hi" @@ -49,6 +57,8 @@ def in_dir(x, *args, **kwds): True >>> in_dir('X') False + >>> in_dir('kwds') + True """ cdef int z = 5 y = "hi" @@ -62,6 +72,8 @@ def in_vars(x, *args, **kwds): True >>> in_vars('X') False + >>> in_vars('kwds') + True """ cdef int z = 5 y = "hi" @@ -113,3 +125,13 @@ def buffers_in_locals(object[char, ndim=1] a): cdef object[unsigned char, ndim=1] b = a return locals() + +def set_comp_scope(): + """ + locals should be evaluated in the outer scope + >>> list(set_comp_scope()) + ['something'] + """ + something = 1 + return { b for b in locals().keys() } + |