Revision: 7871
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7871&view=rev
Author:   astraw
Date:     2009-10-11 19:10:30 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
testing: allow limiting of known failure to known exception class

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/testing/decorators.py

Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py       2009-10-11 
19:09:30 UTC (rev 7870)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py       2009-10-11 
19:10:30 UTC (rev 7871)
@@ -7,7 +7,7 @@
 import numpy as np
 from matplotlib.testing.compare import comparable_formats, compare_images
 
-def knownfailureif(fail_condition, msg=None):
+def knownfailureif(fail_condition, msg=None, known_exception_class=None ):
     """
 
     Assume a will fail if *fail_condition* is True. *fail_condition*
@@ -15,6 +15,9 @@
 
     *msg* is the error message displayed for the test.
 
+    If *known_exception_class* is not None, the failure is only known
+    if the exception is an instance of this class. (Default = None)
+
     """
     # based on numpy.testing.dec.knownfailureif
     if msg is None:
@@ -27,8 +30,12 @@
             try:
                 # Always run the test (to generate images).
                 result = f(*args, **kwargs)
-            except:
+            except Exception, err:
                 if fail_condition:
+                    if known_exception_class is not None:
+                        if not isinstance(err,known_exception_class):
+                            # This is not the expected exception
+                            raise
                     # (Keep the next ultra-long comment so in shows in 
console.)
                     raise KnownFailureTest(msg) # An error here when running 
nose means that you don't have the matplotlib.testing.noseclasses:KnownFailure 
plugin in use.
                 else:


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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to