forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·71 lines (57 loc) · 1.96 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
#
# This allows running the matplotlib tests from the command line: e.g.
#
# $ python tests.py -v -d
#
# The arguments are identical to the arguments accepted by nosetests.
#
# See https://nose.readthedocs.org/ for a detailed description of
# these options.
import os
import sys
import time
import matplotlib
matplotlib.use('agg')
import nose
from nose.plugins import attrib
from matplotlib.testing.noseclasses import KnownFailure
from matplotlib import default_test_modules
from matplotlib import font_manager
# Make sure the font caches are created before starting any possibly
# parallel tests
if font_manager._fmcache is not None:
while not os.path.exists(font_manager._fmcache):
time.sleep(0.5)
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()
if not os.path.isdir(
os.path.join(os.path.dirname(matplotlib.__file__), 'tests')):
raise ImportError("matplotlib test data is not installed")
nose.main(addplugins=[x() for x in plugins],
defaultTest=default_test_modules,
argv=sys.argv + extra_args)
if __name__ == '__main__':
extra_args = []
if '--no-pep8' in sys.argv:
default_test_modules.remove('matplotlib.tests.test_coding_standards')
sys.argv.remove('--no-pep8')
elif '--pep8' in sys.argv:
default_test_modules = ['matplotlib.tests.test_coding_standards']
sys.argv.remove('--pep8')
if '--no-network' in sys.argv:
from matplotlib.testing import disable_internet
disable_internet.turn_off_internet()
extra_args.extend(['--eval-attr="not network"'])
run(extra_args)