Skip to content

Commit

Permalink
fix overview nb execution test
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnsen committed Feb 1, 2024
1 parent c575f01 commit 7b5634a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import os
from logging import getLogger
from pathlib import Path

from myst_nb.converter import myst_to_notebook
from myst_parser.main import MdParserConfig
from nbconvert.preprocessors import ExecutePreprocessor
import pytest
from myst_nb.core.config import NbParserConfig
from myst_nb.core.execute import create_client
from myst_nb.core.read import read_myst_markdown_notebook


@pytest.mark.slow
def test_overview_notebook_execution():
notebook_path = os.path.join(os.getcwd(), "docs", "overview.md")
current_dir = Path(__file__).resolve().parent
project_root = current_dir.parent
notebook_path = project_root / "docs" / "overview.md"

with open(notebook_path, "r") as file:
text = file.read()
config = MdParserConfig()
nb = myst_to_notebook(text, config)
ep = ExecutePreprocessor(timeout=600, kernel_name="python3")
nb = read_myst_markdown_notebook(file.read())

with create_client(
nb, notebook_path, NbParserConfig(), getLogger(), None
) as nb_client:
pass # executes notebook
exec_result = nb_client.exec_metadata
assert exec_result["succeeded"]
assert exec_result["runtime"] > 0

# Execute the notebook
ep.preprocess(nb)
for cell in nb["cells"]:
if cell["cell_type"] == "code":
last_code_cell = cell
Expand Down

0 comments on commit 7b5634a

Please sign in to comment.