Skip to content

Commit

Permalink
Merge pull request statsmodels#5167 from bashtage/fix-notebook-tester
Browse files Browse the repository at this point in the history
BUG/TST: Fix missing SkipTest
  • Loading branch information
josef-pkt authored Sep 11, 2018
2 parents 4b57473 + 8b34b62 commit 35ae4c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ if [ "$LINT" == true ]; then
# pass _all_ flake8 checks
echo "Linting known clean files with strict rules"
flake8 --isolated \
statsmodels/info.py \
statsmodels/resampling/ \
statsmodels/interface/ \
statsmodels/graphics/functional.py \
statsmodels/graphics/tests/test_functional.py \
statsmodels/examples/tests/ \
statsmodels/iolib/smpickle.py \
statsmodels.iolib/tests/test_pickle.py \
statsmodels/iolib/tests/test_pickle.py \
statsmodels/graphics/tsaplots.py \
statsmodels/tsa/regime_switching \
statsmodels/regression/mixed_linear_model.py \
Expand Down
21 changes: 11 additions & 10 deletions statsmodels/examples/tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import pytest

try:
import jupyter_client
import jupyter_client # noqa: F401
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
except ImportError:
pytestmark = pytest.mark.skip(reason='Required packages not available')

try:
import rpy2
import rpy2 # noqa: F401
HAS_RPY2 = True
except ImportError:
HAS_RPY2 = False

try:
import joblib
import joblib # noqa: F401
HAS_JOBLIB = True
except ImportError:
HAS_JOBLIB = False
Expand All @@ -32,7 +32,8 @@
kernel_name = 'python%s' % sys.version_info.major

head, _ = os.path.split(__file__)
NOTEBOOK_DIR = os.path.abspath(os.path.join(head, '..', '..', '..', 'examples', 'notebooks'))
NOTEBOOK_DIR = os.path.join(head, '..', '..', '..', 'examples', 'notebooks')
NOTEBOOK_DIR = os.path.abspath(NOTEBOOK_DIR)

nbs = sorted(glob.glob(os.path.join(NOTEBOOK_DIR, '*.ipynb')))
ids = list(map(lambda p: os.path.split(p)[-1], nbs))
Expand All @@ -54,15 +55,15 @@ def test_notebook(notebook):
filename, _ = os.path.splitext(filename)

if filename in KNOWN_FAILURES:
raise SkipTest('{0} is known to fail'.format(filename))
pytest.skip('{0} is known to fail'.format(filename))
if filename in RPY2_NOTEBOOKS and not HAS_RPY2:
raise SkipTest('{0} requires rpy2 which is not installed'.format(filename))
pytest.skip('{0} since rpy2 is not installed'.format(filename))
if filename in JOBLIB_NOTEBOOKS and not JOBLIB_NOTEBOOKS:
raise SkipTest('{0} requires joblib which is not installed'.format(filename))
pytest.skip('{0} since joblib is not installed'.format(filename))

with io.open(fullfile, encoding='utf-8') as fp:
nb = nbformat.read(fp, as_version=4)

with io.open(fullfile, encoding='utf-8') as f:
nb = nbformat.read(fullfile, as_version=4)

ep = ExecutePreprocessor(allow_errors=False,
timeout=20,
kernel_name=kernel_name)
Expand Down

0 comments on commit 35ae4c3

Please sign in to comment.