From aea62f7f235bd15e268cd96ec28048f3594243d0 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 27 Oct 2015 10:09:56 -0400 Subject: [PATCH 1/7] Reduce dupe between tests.py and matplotlib.test Fix #5328 --- lib/matplotlib/__init__.py | 30 ++++++++++++++++++------------ tests.py | 29 +++++++++-------------------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index b76d94b87d8c..a7c7577be548 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,28 +1509,27 @@ 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) @@ -1532,7 +1538,7 @@ def test(verbosity=1): # 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..8c767180f965 100755 --- a/tests.py +++ b/tests.py @@ -17,32 +17,21 @@ 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], + nose.main(addplugins=plugins, defaultTest=default_test_modules, argv=sys.argv + extra_args) From 0cf5dcb3fb00bf4172ded47b4476d4cafbfeed4e Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 27 Oct 2015 10:50:13 -0400 Subject: [PATCH 2/7] Fix plugin instantiation --- lib/matplotlib/__init__.py | 4 ++-- tests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index a7c7577be548..1e88933c23bb 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1513,7 +1513,7 @@ def _get_extra_test_plugins(): from .testing.noseclasses import KnownFailure from nose.plugins import attrib - return [KnownFailure(), attrib.Plugin()] + return [KnownFailure, attrib.Plugin] def test(verbosity=1): @@ -1532,7 +1532,7 @@ def test(verbosity=1): 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 diff --git a/tests.py b/tests.py index 8c767180f965..529dbe70d112 100755 --- a/tests.py +++ b/tests.py @@ -31,7 +31,7 @@ def run(extra_args): plugins = matplotlib._get_extra_test_plugins() multiprocess._instantiate_plugins = plugins - nose.main(addplugins=plugins, + nose.main(addplugins=[x() for x in plugins], defaultTest=default_test_modules, argv=sys.argv + extra_args) From eb26fade98b26977d493cd36af098971a0272c4c Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 27 Oct 2015 11:35:11 -0400 Subject: [PATCH 3/7] Install mock unconditionally --- .travis.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca5b7ab7b025..36e370ab6ac1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,13 +36,16 @@ matrix: include: - python: 2.7 env: MOCK=mock NUMPY=numpy==1.6 + - python: 2.7 + env: PANDAS=pandas + - python: 3.3 - python: 3.4 - python: 3.5 env: PANDAS=pandas - python: 3.5 env: TEST_ARGS=--pep8 - python: 2.7 - env: BUILD_DOCS=true MOCK=mock + env: BUILD_DOCS=true - python: "nightly" env: PRE=--pre allow_failures: @@ -62,21 +65,14 @@ 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; + pip install $PRE python-dateutil $NUMPY pyparsing pillow sphinx!=1.3.0 mock; fi # Always install from pypi - 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 From ee3b49211e62b3cb9b3dac85392ff93611d8e414 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 28 Oct 2015 09:48:10 -0400 Subject: [PATCH 4/7] Install mock only on Python 2.7 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e370ab6ac1..ece60c46a833 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ matrix: - python: 2.7 env: MOCK=mock NUMPY=numpy==1.6 - python: 2.7 - env: PANDAS=pandas + env: PANDAS=pandas MOCK=mock - python: 3.3 - python: 3.4 - python: 3.5 @@ -65,9 +65,9 @@ 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 mock; + 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 mock; + pip install $PRE python-dateutil $NUMPY pyparsing pillow sphinx!=1.3.0; fi # Always install from pypi - pip install $PRE pep8 cycler From e422b7fa097dda748beb74d9bd7c3a0de7904a57 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 28 Oct 2015 09:58:15 -0400 Subject: [PATCH 5/7] Add mock back in for doc build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ece60c46a833..9da3ec7ad424 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: - python: 3.5 env: TEST_ARGS=--pep8 - python: 2.7 - env: BUILD_DOCS=true + env: BUILD_DOCS=true MOCK=mock - python: "nightly" env: PRE=--pre allow_failures: From 603bce877220d950b66022bd6005c99029705d4a Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 28 Oct 2015 11:03:37 -0400 Subject: [PATCH 6/7] Fix merge --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9da3ec7ad424..a9ae91593b7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,9 +35,7 @@ language: python matrix: include: - python: 2.7 - env: MOCK=mock NUMPY=numpy==1.6 - - python: 2.7 - env: PANDAS=pandas MOCK=mock + env: MOCK=mock - python: 3.3 - python: 3.4 - python: 3.5 From a4715f952b4a96562ac6f0739c9f19a8df03fc12 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 28 Oct 2015 11:04:12 -0400 Subject: [PATCH 7/7] Fix merge --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9ae91593b7d..5fb5c3b590f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,7 @@ language: python matrix: include: - python: 2.7 - env: MOCK=mock - - python: 3.3 + env: MOCK=mock NUMPY=numpy==1.6 - python: 3.4 - python: 3.5 env: PANDAS=pandas