Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backports for 2.0.1 #7279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 16, 2016
Prev Previous commit
Next Next commit
Merge pull request #5330 from mdboom/reduce-testing-duplication
TST: Reduce dupe between tests.py and matplotlib.test

 Conflicts:
	.travis.yml
  • Loading branch information
tacaswell authored and QuLogic committed Oct 16, 2016
commit f9cb9cf719ea17257ee65ef78ac8ca18f2ec8d29
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,13 @@ install:
pip install --upgrade setuptools
- |
# Install dependencies from pypi
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage $MOCK
pip install $PRE -r doc-requirements.txt

# Install nose from a build which has partial
# support for python36 and suport for coverage output suppressing
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose

# 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
Expand Down
32 changes: 19 additions & 13 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,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")

Expand Down Expand Up @@ -1563,37 +1570,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,
Expand Down
27 changes: 8 additions & 19 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down