diff --git a/.travis.yml b/.travis.yml index f145902e50..811eec04f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,11 @@ env: - PYTHON_VERSION=2.7 TESTCMD="--durations=10 --ignore=pymc3/tests/test_examples.py --cov-append --ignore=pymc3/tests/test_distributions_random.py --ignore=pymc3/tests/test_variational_inference.py --ignore=pymc3/tests/test_shared.py --ignore=pymc3/tests/test_smc.py --ignore=pymc3/tests/test_updates.py" - PYTHON_VERSION=2.7 RUN_PYLINT="true" TESTCMD="--durations=10 --cov-append pymc3/tests/test_distributions_random.py pymc3/tests/test_shared.py pymc3/tests/test_smc.py" - PYTHON_VERSION=2.7 TESTCMD="--durations=10 --cov-append pymc3/tests/test_examples.py pymc3/tests/test_variational_inference.py pymc3/tests/test_updates.py" + - PYTHON_VERSION=2.7 TESTCMD="--durations=10 --cov-append pymc3/tests/test_examples_notebooks.py" - PYTHON_VERSION=3.6 TESTCMD="--durations=10 --cov-append --ignore=pymc3/tests/test_examples.py --ignore=pymc3/tests/test_distributions_random.py --ignore=pymc3/tests/test_variational_inference.py --ignore=pymc3/tests/test_shared.py --ignore=pymc3/tests/test_smc.py --ignore=pymc3/tests/test_updates.py" - PYTHON_VERSION=3.6 TESTCMD="--durations=10 --cov-append pymc3/tests/test_distributions_random.py pymc3/tests/test_shared.py pymc3/tests/test_smc.py" - PYTHON_VERSION=3.6 TESTCMD="--durations=10 --cov-append pymc3/tests/test_examples.py pymc3/tests/test_variational_inference.py pymc3/tests/test_updates.py" + - PYTHON_VERSION=3.6 TESTCMD="--durations=10 --cov-append pymc3/tests/test_examples_notebooks.py" script: - . ./scripts/test.sh $TESTCMD diff --git a/pymc3/tests/test_examples_notebooks.py b/pymc3/tests/test_examples_notebooks.py new file mode 100644 index 0000000000..8eebac536e --- /dev/null +++ b/pymc3/tests/test_examples_notebooks.py @@ -0,0 +1,18 @@ +import os +from glob import glob +import nbformat +from nbconvert.preprocessors import ExecutePreprocessor +import pytest + +from .helpers import SeededTest + +notebooks_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'source', 'notebooks') +notebooks_files = [file for file in os.listdir(notebooks_dir) if file.lower().endswith('.ipynb')] + +class TestExamplesNotebooks(SeededTest): + @pytest.mark.parametrize('notebook_filename', notebooks_files) + def test_run_notebook(self, notebook_filename): + with open(os.path.join(notebooks_dir, notebook_filename)) as f: + nb = nbformat.read(f, as_version=4) + ep = ExecutePreprocessor(timeout=300) + ep.preprocess(nb, {'metadata': {'path': notebooks_dir}}) diff --git a/scripts/create_testenv.sh b/scripts/create_testenv.sh index daf1f57895..c2b7d2b289 100755 --- a/scripts/create_testenv.sh +++ b/scripts/create_testenv.sh @@ -50,6 +50,9 @@ pip install pytest pytest-cov nose-parameterized pylint # Install untested, non-required code (linter fails without them) pip install ipython ipywidgets numdifftools +# Install dependencies for examples +pip install keras seaborn + if [ -z ${NO_SETUP} ]; then python setup.py build_ext --inplace fi