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


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45