File: test_execeval.py

package info (click to toggle)
python-altair 5.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 541 bytes parent folder | download
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
from altair.utils.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