μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_eval.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2import os
3
4import pytest
5
6import env # noqa: F401
7from pybind11_tests import eval_ as m
8
9
10def test_evals(capture):
11 with capture:
12 assert m.test_eval_statements()
13 assert capture == "Hello World!"
14
15 assert m.test_eval()
16 assert m.test_eval_single_statement()
17
18 assert m.test_eval_failure()
19
20
21@pytest.mark.xfail("env.PYPY and not env.PY2", raises=RuntimeError)
23 filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py")
24 assert m.test_eval_file(filename)
25
26 assert m.test_eval_file_failure()
27
28
30 assert "__builtins__" in m.eval_empty_globals(None)
31
32 g = {}
33 assert "__builtins__" in m.eval_empty_globals(g)
34 assert "__builtins__" in g
35
36
38 global_, local = m.test_eval_closure()
39
40 assert global_["closure_value"] == 42
41 assert local["closure_value"] == 0
42
43 assert "local_value" not in global_
44 assert local["local_value"] == 0
45
46 assert "func_global" not in global_
47 assert local["func_global"]() == 42
48
49 assert "func_local" not in global_
50 with pytest.raises(NameError):
51 local["func_local"]()
def test_evals(capture)
Definition: test_eval.py:10
def test_eval_file()
Definition: test_eval.py:22
def test_eval_closure()
Definition: test_eval.py:37
def test_eval_empty_globals()
Definition: test_eval.py:29