Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6920 from Kojoley/prepare-for-cross-framework-tes…
…t-suite TST: Prepare for cross-framework test suite
- Loading branch information
Showing
17 changed files
with
286 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from __future__ import (absolute_import, division, print_function, | ||
unicode_literals) | ||
|
||
|
||
def get_extra_test_plugins(): | ||
from .plugins.performgc import PerformGC | ||
from .plugins.knownfailure import KnownFailure | ||
from nose.plugins import attrib | ||
|
||
return [PerformGC, KnownFailure, attrib.Plugin] | ||
|
||
|
||
def get_env(): | ||
env = {'NOSE_COVER_PACKAGE': ['matplotlib', 'mpl_toolkits'], | ||
'NOSE_COVER_HTML': 1, | ||
'NOSE_COVER_NO_PRINT': 1} | ||
return env | ||
|
||
|
||
def check_deps(): | ||
try: | ||
import nose | ||
try: | ||
from unittest import mock | ||
except ImportError: | ||
import mock | ||
except ImportError: | ||
print("matplotlib.test requires nose and mock to run.") | ||
raise | ||
|
||
|
||
def test(verbosity=None, coverage=False, switch_backend_warn=True, **kwargs): | ||
from ... import default_test_modules, get_backend, use | ||
|
||
old_backend = get_backend() | ||
try: | ||
use('agg') | ||
import nose | ||
from nose.plugins import multiprocess | ||
|
||
# Nose doesn't automatically instantiate all of the plugins in the | ||
# child processes, so we have to provide the multiprocess plugin with | ||
# a list. | ||
extra_plugins = get_extra_test_plugins() | ||
multiprocess._instantiate_plugins = extra_plugins | ||
|
||
env = get_env() | ||
if coverage: | ||
env['NOSE_WITH_COVERAGE'] = 1 | ||
|
||
if verbosity is not None: | ||
env['NOSE_VERBOSE'] = verbosity | ||
|
||
success = nose.run( | ||
addplugins=[plugin() for plugin in extra_plugins], | ||
env=env, | ||
defaultTest=default_test_modules, | ||
**kwargs | ||
) | ||
finally: | ||
if old_backend.lower() != 'agg': | ||
use(old_backend, warn=switch_backend_warn) | ||
|
||
return success | ||
|
||
|
||
def knownfail(msg): | ||
from .exceptions import KnownFailureTest | ||
# Keep the next ultra-long comment so it shows in console. | ||
raise KnownFailureTest(msg) # An error here when running nose means that you don't have the matplotlib.testing.nose.plugins:KnownFailure plugin in use. # noqa |
Oops, something went wrong.