Skip to content

Commit

Permalink
add test for tutorial value (#9)
Browse files Browse the repository at this point in the history
this ensures that the tutorials not just run, but also return the correct solution
  • Loading branch information
gidden authored and danielhuppmann committed Feb 5, 2018
1 parent 46ddf84 commit 8089995
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import nbformat
import pytest

import numpy as np

from testing_utils import here

from test_r import r_installed
Expand Down Expand Up @@ -49,12 +51,24 @@ def test_py_transport():
nb, errors = _notebook_run(fname)
assert errors == []

obs = eval(nb.cells[-5]['outputs'][0]['data']['text/plain'])['lvl']
exp = 153.6750030517578
assert np.isclose(obs, exp)


def test_py_transport_scenario():
fname = os.path.join(xport_path, 'py_transport_scenario.ipynb')
nb, errors = _notebook_run(fname)
assert errors == []

obs = eval(nb.cells[-9]['outputs'][0]['data']['text/plain'])['lvl']
exp = 153.6750030517578
assert np.isclose(obs, exp)

obs = eval(nb.cells[-8]['outputs'][0]['data']['text/plain'])['lvl']
exp = 161.3249969482422
assert np.isclose(obs, exp)


@pytest.mark.skipif(not r_installed(), reason='requires R to be installed')
def test_R_transport():
Expand Down

0 comments on commit 8089995

Please sign in to comment.