()
| 14 | |
| 15 | |
| 16 | def test_ipynb(): |
| 17 | nb_path = Path(__file__).parent / 'data/test_nbagg_01.ipynb' |
| 18 | |
| 19 | with TemporaryDirectory() as tmpdir: |
| 20 | out_path = Path(tmpdir, "out.ipynb") |
| 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 = "notebook" |
| 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 = "nbAgg" |
| 41 | backend_outputs = nb.cells[2]["outputs"] |
| 42 | assert backend_outputs[0]["data"]["text/plain"] == f"'{expected_backend}'" |
nothing calls this directly
no test coverage detected
searching dependent graphs…