Skip to content

Commit

Permalink
Merge pull request scikit-learn#3333 from ogrisel/maint-skip-download…
Browse files Browse the repository at this point in the history
…-tests

[MRG+2] MAINT skip tests that require large data download under travis
  • Loading branch information
GaelVaroquaux committed Jul 4, 2014
2 parents 82611e8 + 9a4c9f2 commit 5be7cc2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions continuous_integration/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ python -c "import numpy; print('numpy %s' % numpy.__version__)"
python -c "import scipy; print('scipy %s' % scipy.__version__)"
python setup.py build_ext --inplace

# Skip tests that require large downloads over the network to save bandwith
# usage as travis workers are stateless and therefore traditional local
# disk caching does not work.
export SKLEARN_SKIP_NETWORK_TESTS=1

if [[ "$COVERAGE" == "true" ]]; then
make test-coverage
else
Expand Down
15 changes: 15 additions & 0 deletions doc/tutorial/text_analytics/working_with_text_data_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Fixture module to skip the datasets loading when offline
The 20 newsgroups data is rather large and some CI workers such as travis are
stateless hence will not cache the dataset as regular sklearn users would do.
The following will skip the execution of the working_with_text_data.rst doctests
is the proper environment variable is configured (see the source code of
check_skip_network for more details).
"""
from sklearn.utils.testing import check_skip_network


def setup_module():
check_skip_network()
9 changes: 9 additions & 0 deletions sklearn/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Arnaud Joly
# Denis Engemann
# License: BSD 3 clause
import os
import inspect
import pkgutil
import warnings
Expand Down Expand Up @@ -594,3 +595,11 @@ def clean_warning_registry():
for mod in sys.modules.copy().values():
if hasattr(mod, reg):
getattr(mod, reg).clear()


def check_skip_network():
if int(os.environ.get('SKLEARN_SKIP_NETWORK_TESTS', 0)):
raise SkipTest("Text tutorial requires large dataset download")


with_network = with_setup(check_skip_network)

0 comments on commit 5be7cc2

Please sign in to comment.