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


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:15:58