Skip to content

Commit

Permalink
add test checking if no error messages are left in notebook output (#19)
Browse files Browse the repository at this point in the history
* add test checking if no error messages are left in notebook output. closes #12

* pylint and precommit fixes
  • Loading branch information
slayoo authored Jul 30, 2023
1 parent 269f868 commit 2358cfc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ def test_run_notebooks(notebook_filename, tmp_path):
def test_file_size(notebook_filename):
"""checks if all example Jupyter notebooks have file size less than a certain limit"""
assert os.stat(notebook_filename).st_size * SI.byte < 1 * SI.megabyte


def test_no_errors_or_warnings_in_output(notebook_filename):
"""checks if all example Jupyter notebooks have clear std-err output
(i.e., no errors or warnings) visible"""
with open(notebook_filename, encoding="utf8") as notebook_file:
notebook = nbformat.read(notebook_file, nbformat.NO_CONVERT)
for cell in notebook.cells:
if cell.cell_type == "code":
for output in cell.outputs:
if "name" in output and output["name"] == "stderr":
raise AssertionError(output["text"])

0 comments on commit 2358cfc

Please sign in to comment.