-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1298 from girder/test-notebooks
Test notebooks.
- Loading branch information
Showing
4 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from tempfile import TemporaryDirectory | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.notebook() | ||
@pytest.mark.parametrize('notebook', ['docs/large_image_examples.ipynb']) | ||
def test_notebook_exec(notebook): | ||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
|
||
testDir = os.path.dirname(os.path.realpath(__file__)) | ||
notebookpath = os.path.join(testDir, '..', notebook) | ||
with TemporaryDirectory() as tempDir: | ||
with open(notebookpath) as f: | ||
nb = nbformat.read(f, as_version=4) | ||
ep = ExecutePreprocessor( | ||
timeout=600, kernel_name='python3', | ||
resources={'metadata': {'path': tempDir}}) | ||
try: | ||
result = ep.preprocess(nb) | ||
assert result is not None, f'Got empty notebook for {notebook}' | ||
except Exception as exp: | ||
msg = f'Failed executing {notebook}: {exp}' | ||
raise AssertionError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters