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

Skip to content

Commit 0b4a897

Browse files
committed
Merge pull request #5330 from mdboom/reduce-testing-duplication
TST: Reduce dupe between tests.py and matplotlib.test
2 parents b9957b1 + a4715f9 commit 0b4a897

File tree

3 files changed

+28
-40
lines changed

3 files changed

+28
-40
lines changed

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,14 @@ install:
6262
pip install --upgrade setuptools
6363
# Install only from travis wheelhouse
6464
- if [ -z "$PRE" ]; then
65-
wheelhouse_pip_install python-dateutil $NUMPY $PANDAS pyparsing pillow sphinx!=1.3.0;
65+
wheelhouse_pip_install python-dateutil $NUMPY $PANDAS pyparsing pillow sphinx!=1.3.0 $MOCK;
6666
else
6767
pip install $PRE python-dateutil $NUMPY pyparsing pillow sphinx!=1.3.0;
6868
fi
6969
# Always install from pypi
7070
- pip install $PRE pep8 cycler
7171
- 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose'
7272

73-
# Install mock on python 2. Python 2.6 requires mock 1.0.1
74-
# Since later versions have dropped support
75-
- |
76-
if [[ -n "$MOCK" ]]; then
77-
echo $MOCK
78-
pip install $MOCK
79-
fi;
8073
# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
8174
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
8275
# version since is it basically just a .ttf file

lib/matplotlib/__init__.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,14 @@ def tk_window_focus():
14871487
]
14881488

14891489

1490-
def verify_test_dependencies():
1490+
def _init_tests():
1491+
try:
1492+
import faulthandler
1493+
except ImportError:
1494+
pass
1495+
else:
1496+
faulthandler.enable()
1497+
14911498
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
14921499
raise ImportError("matplotlib test data is not installed")
14931500

@@ -1502,37 +1509,36 @@ def verify_test_dependencies():
15021509
raise
15031510

15041511

1512+
def _get_extra_test_plugins():
1513+
from .testing.noseclasses import KnownFailure
1514+
from nose.plugins import attrib
1515+
1516+
return [KnownFailure, attrib.Plugin]
1517+
1518+
15051519
def test(verbosity=1):
15061520
"""run the matplotlib test suite"""
1507-
verify_test_dependencies()
1508-
try:
1509-
import faulthandler
1510-
except ImportError:
1511-
pass
1512-
else:
1513-
faulthandler.enable()
1521+
_init_tests()
15141522

15151523
old_backend = rcParams['backend']
15161524
try:
15171525
use('agg')
15181526
import nose
15191527
import nose.plugins.builtin
1520-
from .testing.noseclasses import KnownFailure
15211528
from nose.plugins.manager import PluginManager
15221529
from nose.plugins import multiprocess
15231530

15241531
# store the old values before overriding
1525-
plugins = []
1526-
plugins.append(KnownFailure())
1532+
plugins = _get_extra_test_plugins()
15271533
plugins.extend([plugin() for plugin in nose.plugins.builtin.plugins])
15281534

1529-
manager = PluginManager(plugins=plugins)
1535+
manager = PluginManager(plugins=[x() for x in plugins])
15301536
config = nose.config.Config(verbosity=verbosity, plugins=manager)
15311537

15321538
# Nose doesn't automatically instantiate all of the plugins in the
15331539
# child processes, so we have to provide the multiprocess plugin with
15341540
# a list.
1535-
multiprocess._instantiate_plugins = [KnownFailure]
1541+
multiprocess._instantiate_plugins = plugins
15361542

15371543
success = nose.run(
15381544
defaultTest=default_test_modules,

tests.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,19 @@
1717
matplotlib.use('agg')
1818

1919
import nose
20-
from nose.plugins import attrib
21-
from matplotlib.testing.noseclasses import KnownFailure
2220
from matplotlib import default_test_modules
2321

24-
plugins = [KnownFailure, attrib.Plugin]
25-
26-
# Nose doesn't automatically instantiate all of the plugins in the
27-
# child processes, so we have to provide the multiprocess plugin with
28-
# a list.
29-
from nose.plugins import multiprocess
30-
multiprocess._instantiate_plugins = plugins
31-
3222

3323
def run(extra_args):
34-
try:
35-
import faulthandler
36-
except ImportError:
37-
pass
38-
else:
39-
faulthandler.enable()
24+
from nose.plugins import multiprocess
25+
26+
matplotlib._init_tests()
4027

41-
if not os.path.isdir(
42-
os.path.join(os.path.dirname(matplotlib.__file__), 'tests')):
43-
raise ImportError("matplotlib test data is not installed")
28+
# Nose doesn't automatically instantiate all of the plugins in the
29+
# child processes, so we have to provide the multiprocess plugin with
30+
# a list.
31+
plugins = matplotlib._get_extra_test_plugins()
32+
multiprocess._instantiate_plugins = plugins
4433

4534
nose.main(addplugins=[x() for x in plugins],
4635
defaultTest=default_test_modules,

0 commit comments

Comments
 (0)