Revision: 7659
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7659&view=rev
Author:   astraw
Date:     2009-09-06 20:13:06 +0000 (Sun, 06 Sep 2009)

Log Message:
-----------
testing: add matplotlib.test() function to run tests

Modified Paths:
--------------
    trunk/matplotlib/doc/devel/coding_guide.rst
    trunk/matplotlib/lib/matplotlib/__init__.py
    trunk/matplotlib/test/run-mpl-test.py

Modified: trunk/matplotlib/doc/devel/coding_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 19:29:45 UTC (rev 
7658)
+++ trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 20:13:06 UTC (rev 
7659)
@@ -774,10 +774,6 @@
 -----------------------------------------
 
 Let's say you've added a new module named
-``matplotlib.tests.test_whizbang_features``.  For the buildbot slave
-machines to know to run a test, nose must look in that module. To add
-a module to the list searched, add the line::
-
-  args.append('matplotlib.tests.test_whizbang_features')
-
-into :file:`test/run-mpl-test.py`.
+``matplotlib.tests.test_whizbang_features``.  To add this module to
+the list of default tests, append its name to ``default_test_modules``
+in :file:`lib/matplotlib/__init__.py`.

Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-06 19:29:45 UTC (rev 
7658)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-06 20:13:06 UTC (rev 
7659)
@@ -876,7 +876,33 @@
             pass
         # we don't want to assume all -d flags are backends, eg -debug
 
+default_test_modules = [
+    'matplotlib.tests.test_basic',
+    'matplotlib.tests.test_transforms',
+    'matplotlib.tests.test_spines',
+    ]
 
+def test(verbosity=0):
+    """run the matplotlib test suite"""
+    import nose
+    import nose.plugins.builtin
+    from testing.noseclasses import KnownFailure
+    from nose.plugins.manager import PluginManager
+
+    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=default_test_modules,
+                        config=config,
+                        )
+    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'])

Modified: trunk/matplotlib/test/run-mpl-test.py
===================================================================
--- trunk/matplotlib/test/run-mpl-test.py       2009-09-06 19:29:45 UTC (rev 
7658)
+++ trunk/matplotlib/test/run-mpl-test.py       2009-09-06 20:13:06 UTC (rev 
7659)
@@ -44,6 +44,7 @@
 
 import nose
 from mplTest import MplNosePlugin, path_utils
+import matplotlib
 from matplotlib.testing.noseclasses import KnownFailure
 
 if '--clean' in args:
@@ -91,9 +92,8 @@
 
 ### Run nose
 args.append('.')
-args.append('matplotlib.tests.test_basic')
-args.append('matplotlib.tests.test_transforms')
-args.append('matplotlib.tests.test_spines')
+args.extend( matplotlib.default_test_modules )
+
 success = nose.run( argv = args,
                     plugins = [ MplNosePlugin(), KnownFailure() ] )
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to