Spaces:
Running
Running
File size: 530 Bytes
ba2f5d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from ..execeval import eval_block
HAS_RETURN = """
x = 4
y = 2 * x
3 * y
"""
NO_RETURN = """
x = 4
y = 2 * x
z = 3 * y
"""
def test_eval_block_with_return():
_globals = {}
result = eval_block(HAS_RETURN, _globals)
assert result == 24
assert _globals["x"] == 4
assert _globals["y"] == 8
def test_eval_block_without_return():
_globals = {}
result = eval_block(NO_RETURN, _globals)
assert result is None
assert _globals["x"] == 4
assert _globals["y"] == 8
assert _globals["z"] == 24
|