MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_ipynb

Function test_ipynb

lib/matplotlib/tests/test_backend_inline.py:15–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def test_ipynb():
16 nb_path = Path(__file__).parent / 'data/test_inline_01.ipynb'
17
18 with TemporaryDirectory() as tmpdir:
19 out_path = Path(tmpdir, "out.ipynb")
20
21 subprocess_run_for_testing(
22 ["jupyter", "nbconvert", "--to", "notebook",
23 "--execute", "--ExecutePreprocessor.timeout=500",
24 "--output", str(out_path), str(nb_path)],
25 env={**os.environ, "IPYTHONDIR": tmpdir},
26 check=True)
27 with out_path.open() as out:
28 nb = nbformat.read(out, nbformat.current_nbformat)
29
30 errors = [output for cell in nb.cells for output in cell.get("outputs", [])
31 if output.output_type == "error"]
32 assert not errors
33
34 import IPython
35 if IPython.version_info[:2] >= (8, 24):
36 expected_backend = "inline"
37 else:
38 # This code can be removed when Python 3.12, the latest version supported by
39 # IPython < 8.24, reaches end-of-life in late 2028.
40 expected_backend = "module://matplotlib_inline.backend_inline"
41 backend_outputs = nb.cells[2]["outputs"]
42 assert backend_outputs[0]["data"]["text/plain"] == f"'{expected_backend}'"
43
44 image = nb.cells[1]["outputs"][1]["data"]
45 assert image["text/plain"] == "<Figure size 300x200 with 1 Axes>"
46 assert "image/png" in image

Callers

nothing calls this directly

Calls 4

PathClass · 0.85
openMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…