diff --git a/.travis.yml b/.travis.yml index ca5b7ab7b025..5fb5c3b590f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ install: pip install --upgrade setuptools # Install only from travis wheelhouse - if [ -z "$PRE" ]; then - wheelhouse_pip_install python-dateutil $NUMPY $PANDAS pyparsing pillow sphinx!=1.3.0; + wheelhouse_pip_install python-dateutil $NUMPY $PANDAS pyparsing pillow sphinx!=1.3.0 $MOCK; else pip install $PRE python-dateutil $NUMPY pyparsing pillow sphinx!=1.3.0; fi @@ -70,13 +70,6 @@ install: - pip install $PRE pep8 cycler - 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose' - # Install mock on python 2. Python 2.6 requires mock 1.0.1 - # Since later versions have dropped support - - | - if [[ -n "$MOCK" ]]; then - echo $MOCK - pip install $MOCK - fi; # We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not # availible in the Ubuntu version used by Travis but we can manually install the deb from a later # version since is it basically just a .ttf file diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index b76d94b87d8c..1e88933c23bb 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1487,7 +1487,14 @@ def tk_window_focus(): ] -def verify_test_dependencies(): +def _init_tests(): + try: + import faulthandler + except ImportError: + pass + else: + faulthandler.enable() + if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')): raise ImportError("matplotlib test data is not installed") @@ -1502,37 +1509,36 @@ def verify_test_dependencies(): raise +def _get_extra_test_plugins(): + from .testing.noseclasses import KnownFailure + from nose.plugins import attrib + + return [KnownFailure, attrib.Plugin] + + def test(verbosity=1): """run the matplotlib test suite""" - verify_test_dependencies() - try: - import faulthandler - except ImportError: - pass - else: - faulthandler.enable() + _init_tests() old_backend = rcParams['backend'] try: use('agg') import nose import nose.plugins.builtin - from .testing.noseclasses import KnownFailure from nose.plugins.manager import PluginManager from nose.plugins import multiprocess # store the old values before overriding - plugins = [] - plugins.append(KnownFailure()) + plugins = _get_extra_test_plugins() plugins.extend([plugin() for plugin in nose.plugins.builtin.plugins]) - manager = PluginManager(plugins=plugins) + manager = PluginManager(plugins=[x() for x in plugins]) config = nose.config.Config(verbosity=verbosity, plugins=manager) # Nose doesn't automatically instantiate all of the plugins in the # child processes, so we have to provide the multiprocess plugin with # a list. - multiprocess._instantiate_plugins = [KnownFailure] + multiprocess._instantiate_plugins = plugins success = nose.run( defaultTest=default_test_modules, diff --git a/tests.py b/tests.py index 70dfeb37974c..529dbe70d112 100755 --- a/tests.py +++ b/tests.py @@ -17,30 +17,19 @@ matplotlib.use('agg') import nose -from nose.plugins import attrib -from matplotlib.testing.noseclasses import KnownFailure from matplotlib import default_test_modules -plugins = [KnownFailure, attrib.Plugin] - -# Nose doesn't automatically instantiate all of the plugins in the -# child processes, so we have to provide the multiprocess plugin with -# a list. -from nose.plugins import multiprocess -multiprocess._instantiate_plugins = plugins - def run(extra_args): - try: - import faulthandler - except ImportError: - pass - else: - faulthandler.enable() + from nose.plugins import multiprocess + + matplotlib._init_tests() - if not os.path.isdir( - os.path.join(os.path.dirname(matplotlib.__file__), 'tests')): - raise ImportError("matplotlib test data is not installed") + # Nose doesn't automatically instantiate all of the plugins in the + # child processes, so we have to provide the multiprocess plugin with + # a list. + plugins = matplotlib._get_extra_test_plugins() + multiprocess._instantiate_plugins = plugins nose.main(addplugins=[x() for x in plugins], defaultTest=default_test_modules,