From 922fc1c41157e151ac3f495d606f4884606cf2dc Mon Sep 17 00:00:00 2001 From: sdkenney42 <128510721+sdkenney42@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:07:30 -0600 Subject: [PATCH] Update tests.py --- tests/tests.py | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/tests/tests.py b/tests/tests.py index f6f3a99..c675bae 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,42 +1,22 @@ import os -import shutil -import pytest import nbformat from nbconvert.preprocessors import ExecutePreprocessor -TEST_TMPDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".cache") - -# ########################## -# Tests setup function -# ########################## -def setup_function(): - if not os.path.exists(TEST_TMPDIR): - os.mkdir(TEST_TMPDIR) - - -# ########################## -# Tests executing the notebook -# ########################## -def test_notebook(): +def test_notebook(tmpdir): + """Test the notebook.""" + tmp = tmpdir.mkdir('sub') # Open the notebook with open("index.ipynb", "r") as f: nb = nbformat.read(f, as_version=4) # Process the notebook ep = ExecutePreprocessor(timeout=600, kernel_name="python3") - ep.preprocess(nb, {"metadata": {"path": TEST_TMPDIR}}) + ep.preprocess(nb, {"metadata": {"path": os.getcwd()}}) # Save the executed notebook - out_nb = os.path.join(TEST_TMPDIR, "executed_notebook.ipynb") + out_nb = os.path.join(tmp, "executed_notebook.ipynb") with open(out_nb, "w", encoding="utf-8") as f: nbformat.write(nb, f) assert os.path.exists(out_nb) - - -# ############################## -# Clean up test files -# ############################## -def teardown_function(): - shutil.rmtree(TEST_TMPDIR)