Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Reduce dupe between tests.py and matplotlib.test
Fix #5328
  • Loading branch information
mdboom committed Oct 28, 2015
commit aea62f7f235bd15e268cd96ec28048f3594243d0
30 changes: 18 additions & 12 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,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)
Expand All @@ -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,
Expand Down
29 changes: 9 additions & 20 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down