diff --git a/pyproject.toml b/pyproject.toml index 8ecdc47..69072f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ test = [ source = "vcs" [tool.hatch.envs.test] +python = "3.12" features = ["test"] [tool.hatch.envs.test.scripts] run = "pytest -vv {args}" diff --git a/tests/data/notebooks/example.ipynb b/tests/data/notebooks/example.ipynb index 2755585..b41c331 100644 --- a/tests/data/notebooks/example.ipynb +++ b/tests/data/notebooks/example.ipynb @@ -7,7 +7,10 @@ "outputs": [], "source": [ "import random\n", - "random.randint(0, 10)" + "from pathlib import Path\n", + "\n", + "r = random.randint(0, 10)\n", + "Path(\"r.txt\").write_text(str(r))\n" ] } ], diff --git a/tests/test_runner.py b/tests/test_runner.py index ba39cb1..b486284 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -1,3 +1,5 @@ +import shutil +from contextlib import chdir from pathlib import Path from typing import TYPE_CHECKING @@ -54,5 +56,8 @@ def mk_nb() -> None: assert exc_rr.value.traceback == exc_orig.value.traceback -def test_cli() -> None: - main([f"--preludes={preludes_dir}", str(nbs_dir)]) +def test_cli(tmp_path: Path) -> None: + with chdir(tmp_path): + shutil.copytree(nbs_dir, "notebooks") + main([f"--preludes={preludes_dir}", "notebooks"]) + assert Path("notebooks/r.txt").read_text() == "6"