1# -*- coding: utf-8 -*-
2import os
3
4import pytest
5
6import env  # noqa: F401
7
8from pybind11_tests import eval_ as m
9
10
11def 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 and not env.PY2", raises=RuntimeError)
23def test_eval_file():
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
30def test_eval_empty_globals():
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