2023-04-24 16:05:07 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
import os
|
|
|
|
import nbformat
|
|
|
|
from nbconvert.preprocessors import ExecutePreprocessor
|
|
|
|
|
|
|
|
ROOT = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
class TestNotebooks(TestCase):
|
|
|
|
def test_tutorial(self):
|
2023-04-24 16:46:09 +00:00
|
|
|
notebook = os.path.join(ROOT, "../docs/tutorial/soil_tutorial.ipynb")
|
2023-04-24 16:05:07 +00:00
|
|
|
with open(notebook) as f:
|
|
|
|
nb = nbformat.read(f, as_version=4)
|
|
|
|
ep = ExecutePreprocessor(timeout=60000, kernel_name='python3')
|
|
|
|
try:
|
|
|
|
assert ep.preprocess(nb) is not None, f"Got empty notebook for {notebook}"
|
|
|
|
except Exception:
|
|
|
|
assert False, f"Failed executing {notebook}"
|
|
|
|
|