diff --git a/pyproject.toml b/pyproject.toml index b12ccc2dc..1b72d39b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ Source = "https://github.com/amazon-braket/amazon-braket-examples" dependencies = [ "jupyter", "nbconvert", + "nbformat", "pytest", "pytest-rerunfailures", "pytest-xdist[psutil]", diff --git a/test/integ_tests/test_all_notebooks.py b/test/integ_tests/test_all_notebooks.py index 921f61551..e823f68ca 100644 --- a/test/integ_tests/test_all_notebooks.py +++ b/test/integ_tests/test_all_notebooks.py @@ -1,5 +1,10 @@ import logging import os +import pytest +import nbformat + +from testbook import testbook +from nbconvert import HTMLExporter from importlib.machinery import SourceFileLoader import pytest @@ -109,6 +114,14 @@ def test_notebook_to_html_conversion(notebook_dir, notebook_file, mock_level, ht html_exporter.from_file(notebook_file) +@pytest.mark.parametrize("notebook_dir, notebook_file", test_notebooks) +def test_valid_nb_format(notebook_dir, notebook_file, mock_level): + os.chdir(root_path) + with open(os.path.join(notebook_dir, notebook_file), "r") as file: + nb_doc = nbformat.reader.read(file) + nbformat.validator.validate(nb_doc) + + def test_record(): # Set the path here to record results. notebook_file_search = ""