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

Skip to content

Commit f9cb9cf

Browse files
tacaswellQuLogic
authored andcommitted
Merge pull request #5330 from mdboom/reduce-testing-duplication
TST: Reduce dupe between tests.py and matplotlib.test Conflicts: .travis.yml
1 parent 9111ee2 commit f9cb9cf

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
@@ -77,20 +77,13 @@ install:
7777
pip install --upgrade setuptools
7878
- |
7979
# Install dependencies from pypi
80-
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage
80+
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage $MOCK
8181
pip install $PRE -r doc-requirements.txt
8282
8383
# Install nose from a build which has partial
8484
# support for python36 and suport for coverage output suppressing
8585
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose
8686
87-
# Install mock on python 2. Python 2.6 requires mock 1.0.1
88-
# Since later versions have dropped support
89-
- |
90-
if [[ -n "$MOCK" ]]; then
91-
echo $MOCK
92-
pip install $MOCK
93-
fi;
9487
# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
9588
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
9689
# 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
@@ -1528,7 +1528,14 @@ def tk_window_focus():
15281528
]
15291529

15301530

1531-
def verify_test_dependencies():
1531+
def _init_tests():
1532+
try:
1533+
import faulthandler
1534+
except ImportError:
1535+
pass
1536+
else:
1537+
faulthandler.enable()
1538+
15321539
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
15331540
raise ImportError("matplotlib test data is not installed")
15341541

@@ -1563,37 +1570,36 @@ def verify_test_dependencies():
15631570
raise
15641571

15651572

1573+
def _get_extra_test_plugins():
1574+
from .testing.noseclasses import KnownFailure
1575+
from nose.plugins import attrib
1576+
1577+
return [KnownFailure, attrib.Plugin]
1578+
1579+
15661580
def test(verbosity=1):
15671581
"""run the matplotlib test suite"""
1568-
verify_test_dependencies()
1569-
try:
1570-
import faulthandler
1571-
except ImportError:
1572-
pass
1573-
else:
1574-
faulthandler.enable()
1582+
_init_tests()
15751583

15761584
old_backend = rcParams['backend']
15771585
try:
15781586
use('agg')
15791587
import nose
15801588
import nose.plugins.builtin
1581-
from .testing.noseclasses import KnownFailure
15821589
from nose.plugins.manager import PluginManager
15831590
from nose.plugins import multiprocess
15841591

15851592
# store the old values before overriding
1586-
plugins = []
1587-
plugins.append(KnownFailure())
1593+
plugins = _get_extra_test_plugins()
15881594
plugins.extend([plugin() for plugin in nose.plugins.builtin.plugins])
15891595

1590-
manager = PluginManager(plugins=plugins)
1596+
manager = PluginManager(plugins=[x() for x in plugins])
15911597
config = nose.config.Config(verbosity=verbosity, plugins=manager)
15921598

15931599
# Nose doesn't automatically instantiate all of the plugins in the
15941600
# child processes, so we have to provide the multiprocess plugin with
15951601
# a list.
1596-
multiprocess._instantiate_plugins = [KnownFailure]
1602+
multiprocess._instantiate_plugins = plugins
15971603

15981604
success = nose.run(
15991605
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)