-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathtest_eval.py
More file actions
42 lines (35 loc) · 1.34 KB
/
test_eval.py
File metadata and controls
42 lines (35 loc) · 1.34 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
"""Test the `eval` directives and roles."""
import pytest
@pytest.mark.sphinx_params("with_eval.md", conf={"nb_execution_mode": "inline"})
def test_sphinx(sphinx_run, clean_doctree, file_regression):
"""Test a sphinx build."""
sphinx_run.build()
# print(sphinx_run.status())
# print(sphinx_run.warnings())
assert sphinx_run.warnings() == ""
doctree = clean_doctree(sphinx_run.get_resolved_doctree("with_eval"))
file_regression.check(
doctree.pformat(),
encoding="utf-8",
)
@pytest.mark.sphinx_params(
"with_eval_executed.ipynb", conf={"nb_execution_mode": "off"}
)
def test_no_build(sphinx_run, clean_doctree, file_regression):
"""Test using eval from cell metadata."""
sphinx_run.build()
assert sphinx_run.warnings() == ""
doctree = clean_doctree(sphinx_run.get_resolved_doctree("with_eval_executed"))
file_regression.check(doctree.pformat(), encoding="utf-8")
@pytest.mark.sphinx_params("with_eval.md", conf={"nb_execution_mode": "off"})
def test_no_build_error(sphinx_run):
"""Test that lack of execution results errors."""
sphinx_run.build()
assert (
"Cell 2 does not contain execution result for variable 'a'"
in sphinx_run.warnings()
)
assert (
"Cell 4 does not contain execution result for variable 'img'"
in sphinx_run.warnings()
)