Skip to content

Commit

Permalink
Add infrastructure for testing of mpl toolkits and a single test to d…
Browse files Browse the repository at this point in the history
…emonstrate.

"python tests.py" runs all tests from mpl and the toolkits.
mpl_toolkits.test() runs tests of the toolkits only.
  • Loading branch information
jenshnielsen committed Nov 21, 2012
1 parent ecb4802 commit ec0fd15
Show file tree
Hide file tree
Showing 8 changed files with 1,137 additions and 6 deletions.
47 changes: 47 additions & 0 deletions lib/mpl_toolkits/__init__.py
@@ -1,4 +1,51 @@
import sys
from matplotlib import Verbose
from matplotlib import rcParams
from matplotlib import __version__
from matplotlib import use

verbose = Verbose()

try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
pass # must not have setuptools

toolkits_test_modules = [
'mpl_toolkits.tests.test_axesgrid1',
]

def test(verbosity=1):
"""run the matplotlib test suite"""
old_backend = rcParams['backend']
try:
use('agg')
import nose
import nose.plugins.builtin
from matplotlib.testing.noseclasses import KnownFailure
from nose.plugins.manager import PluginManager

# store the old values before overriding
plugins = []
plugins.append( KnownFailure() )
plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )

manager = PluginManager(plugins = plugins)
config = nose.config.Config(verbosity = verbosity, plugins = manager)

success = nose.run( defaultTest = toolkits_test_modules,
config=config,
)
finally:
if old_backend.lower() != 'agg':
use(old_backend)

return success

test.__test__ = False # nose: this function is not a test

verbose.report('matplotlib version %s'%__version__)
verbose.report('verbose.level %s'%verbose.level)
verbose.report('interactive is %s'%rcParams['interactive'])
verbose.report('platform is %s'%sys.platform)
verbose.report('loaded modules: %s'%sys.modules.iterkeys(), 'debug')
16 changes: 16 additions & 0 deletions lib/mpl_toolkits/tests/__init__.py
@@ -0,0 +1,16 @@
from __future__ import print_function
from matplotlib import rcParams, rcdefaults, use

_multiprocess_can_split_ = True

def setup():
use('Agg', warn=False) # use Agg backend for these tests

# These settings *must* be hardcoded for running the comparison
# tests and are not necessarily the default values as specified in
# rcsetup.py
rcdefaults() # Start with all defaults
rcParams['font.family'] = 'Bitstream Vera Sans'
rcParams['text.hinting'] = False
rcParams['text.hinting_factor'] = 8
rcParams['text.antialiased'] = False
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec0fd15

Please sign in to comment.