Files
RustPython/extra_tests/snippets/stdlib_sys_getframe.py
2022-05-04 02:54:59 +09:00

22 lines
461 B
Python

import sys
value = 189
locals_dict = sys._getframe().f_locals
assert locals_dict['value'] == 189
foo = 'bar'
assert locals_dict['foo'] == foo
def test_function():
x = 17
assert sys._getframe().f_locals is not locals_dict
assert sys._getframe().f_locals['x'] == 17
assert sys._getframe(1).f_locals['foo'] == 'bar'
test_function()
class TestClass():
def __init__(self):
assert sys._getframe().f_locals['self'] == self
TestClass()