-
Notifications
You must be signed in to change notification settings - Fork 51
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 #166 from kanderso-nrel/nbdime_pytest050
Add support for pytest>=0.5.0 to nbdime_reporter.py
- Loading branch information
Showing
3 changed files
with
45 additions
and
3 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,32 @@ | ||
|
||
from utils import build_nb, add_expected_plaintext_outputs | ||
|
||
import nbdime | ||
import nbformat | ||
import os | ||
|
||
|
||
def test_nbdime(testdir, mocker): | ||
|
||
# Make a test notebook where output doesn't match input | ||
nb = build_nb(["1+1", "1+1"], mark_run=True) | ||
add_expected_plaintext_outputs(nb, ["2", "3"]) | ||
# Write notebook to test dir | ||
filename = 'test_nbdime.ipynb' | ||
nbformat.write(nb, os.path.join(str(testdir.tmpdir), filename)) | ||
|
||
# patch the run_server function so that it doesn't actually | ||
# spawn a server and display the diff. But the diff is still | ||
# calculated. | ||
mocker.patch('nbdime.webapp.nbdiffweb.run_server') | ||
result = testdir.runpytest_inprocess('--nbval', | ||
'--nbval-current-env', | ||
'--nbdime', | ||
filename) | ||
# run_server() is only called if there is a discrepancy in the notebook. | ||
# so it should have been called in this case: | ||
nbdime.webapp.nbdiffweb.run_server.assert_called_once() | ||
|
||
# note: this import must be AFTER the mocker.patch | ||
from nbval.nbdime_reporter import EXIT_TESTSFAILED | ||
assert result.ret == EXIT_TESTSFAILED |