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

Skip to content

Reduce dupe between tests.py and matplotlib.test #5330

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 7 commits into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,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;
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
Expand Down
32 changes: 19 additions & 13 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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,
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