|
| 1 | +import os |
| 2 | +from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin |
| 3 | + |
| 4 | +class KnownFailureTest(Exception): |
| 5 | + '''Raise this exception to mark a test as a known failing test.''' |
| 6 | + pass |
| 7 | + |
| 8 | +class KnownFailure(ErrorClassPlugin): |
| 9 | + '''Plugin that installs a KNOWNFAIL error class for the |
| 10 | + KnownFailureClass exception. When KnownFailureTest is raised, |
| 11 | + the exception will be logged in the knownfail attribute of the |
| 12 | + result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the |
| 13 | + exception will not be counted as an error or failure. |
| 14 | +
|
| 15 | + This is based on numpy.testing.noseclasses.KnownFailure. |
| 16 | + ''' |
| 17 | + enabled = True |
| 18 | + knownfail = ErrorClass(KnownFailureTest, |
| 19 | + label='KNOWNFAIL', |
| 20 | + isfailure=False) |
| 21 | + |
| 22 | + def options(self, parser, env=os.environ): |
| 23 | + env_opt = 'NOSE_WITHOUT_KNOWNFAIL' |
| 24 | + parser.add_option('--no-knownfail', action='store_true', |
| 25 | + dest='noKnownFail', default=env.get(env_opt, False), |
| 26 | + help='Disable special handling of KnownFailureTest ' |
| 27 | + 'exceptions') |
| 28 | + |
| 29 | + def configure(self, options, conf): |
| 30 | + if not self.can_configure: |
| 31 | + return |
| 32 | + self.conf = conf |
| 33 | + disable = getattr(options, 'noKnownFail', False) |
| 34 | + if disable: |
| 35 | + self.enabled = False |
| 36 | + |
| 37 | + def addError( self, test, err ): |
| 38 | + # Fixme (Really weird): if I don't leave empty method here, |
| 39 | + # nose gets confused and KnownFails become testing errors when |
| 40 | + # using the MplNosePlugin and MplTestCase. |
| 41 | + pass |
0 commit comments