##// END OF EJS Templates
make know failures report as 'K'...
Paul Ivanov -
Show More
@@ -0,0 +1,41 b''
1 # IPython: modified copy of numpy.testing.noseclasses, so
2 # IPython.external._decorators works without numpy being installed.
3
4 # These classes implement a "known failure" error class.
5
6 import os
7
8 from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
9
10 class KnownFailureTest(Exception):
11 '''Raise this exception to mark a test as a known failing test.'''
12 pass
13
14
15 class KnownFailure(ErrorClassPlugin):
16 '''Plugin that installs a KNOWNFAIL error class for the
17 KnownFailureClass exception. When KnownFailureTest is raised,
18 the exception will be logged in the knownfail attribute of the
19 result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the
20 exception will not be counted as an error or failure.'''
21 enabled = True
22 knownfail = ErrorClass(KnownFailureTest,
23 label='KNOWNFAIL',
24 isfailure=False)
25
26 def options(self, parser, env=os.environ):
27 env_opt = 'NOSE_WITHOUT_KNOWNFAIL'
28 parser.add_option('--no-knownfail', action='store_true',
29 dest='noKnownFail', default=env.get(env_opt, False),
30 help='Disable special handling of KnownFailureTest '
31 'exceptions')
32
33 def configure(self, options, conf):
34 if not self.can_configure:
35 return
36 self.conf = conf
37 disable = getattr(options, 'noKnownFail', False)
38 if disable:
39 self.enabled = False
40
41
@@ -1,4 +1,7 b''
1 1 try:
2 2 from numpy.testing.decorators import *
3 from numpy.testing.noseclasses import KnownFailure
3 4 except ImportError:
4 5 from _decorators import *
6 # KnownFailure imported in _decorators from local version of
7 # noseclasses which is in _numpy_testing_noseclasses
@@ -14,7 +14,6 b' function name, setup and teardown functions and so on - see'
14 14
15 15 """
16 16 import warnings
17 import sys
18 17
19 18 # IPython changes: make this work if numpy not available
20 19 # Original code:
@@ -26,6 +25,11 b' try:'
26 25 except ImportError:
27 26 from _numpy_testing_utils import WarningManager, WarningMessage
28 27
28 try:
29 from numpy.testing.noseclasses import KnownFailure, KnownFailureTest
30 except ImportError:
31 from _numpy_testing_noseclasses import KnownFailure, KnownFailureTest
32
29 33 # End IPython changes
30 34
31 35 def slow(t):
@@ -34,7 +38,7 b' def slow(t):'
34 38
35 39 The exact definition of a slow test is obviously both subjective and
36 40 hardware-dependent, but in general any individual test that requires more
37 than a second or two should be labeled as slow (the whole suite consits of
41 than a second or two should be labeled as slow (the whole suite consists of
38 42 thousands of tests, so even a second is significant).
39 43
40 44 Parameters
@@ -172,7 +176,6 b' def skipif(skip_condition, msg=None):'
172 176
173 177 return skip_decorator
174 178
175
176 179 def knownfailureif(fail_condition, msg=None):
177 180 """
178 181 Make function raise KnownFailureTest exception if given condition is true.
@@ -216,7 +219,6 b' def knownfailureif(fail_condition, msg=None):'
216 219 # Local import to avoid a hard nose dependency and only incur the
217 220 # import time overhead at actual test-time.
218 221 import nose
219 from noseclasses import KnownFailureTest
220 222 def knownfailer(*args, **kwargs):
221 223 if fail_val():
222 224 raise KnownFailureTest, msg
@@ -255,7 +257,6 b' def deprecated(conditional=True):'
255 257 # Local import to avoid a hard nose dependency and only incur the
256 258 # import time overhead at actual test-time.
257 259 import nose
258 from noseclasses import KnownFailureTest
259 260
260 261 def _deprecated_imp(*args, **kwargs):
261 262 # Poor man's replacement for the with statement
@@ -1,14 +1,10 b''
1 # IPython: modified copy of numpy.testing.utils, so numpy.testing.decorators
2 # works without numpy being installed.
1 # IPython: modified copy of numpy.testing.utils, so
2 # IPython.external._decorators works without numpy being installed.
3 3 """
4 4 Utility function to facilitate testing.
5 5 """
6 6
7 import os
8 7 import sys
9 import re
10 import operator
11 import types
12 8 import warnings
13 9
14 10 # The following two classes are copied from python 2.6 warnings module (context
@@ -24,9 +24,10 b' Lightweight testing that remains unittest-compatible.'
24 24 recognize it as such. This will make it easier to migrate away from Nose if
25 25 we ever need/want to while maintaining very lightweight tests.
26 26
27 NOTE: This file contains IPython-specific decorators and imports the
28 numpy.testing.decorators file, which we've copied verbatim. Any of our own
29 code will be added at the bottom if we end up extending this.
27 NOTE: This file contains IPython-specific decorators. Using the machinery in
28 IPython.external.decorators, we import either numpy.testing.decorators if numpy is
29 available, OR use equivalent code in IPython.external._decorators, which
30 we've copied verbatim from numpy.
30 31
31 32 Authors
32 33 -------
@@ -319,7 +320,7 b' skipif_not_numpy = skipif(module_not_available(\'numpy\'),"This test requires nump'
319 320
320 321 skipif_not_sympy = skipif(module_not_available('sympy'),"This test requires sympy")
321 322
322 skip_known_failure = skip('This test is known to fail')
323 skip_known_failure = knownfailureif(True,'This test is known to fail')
323 324
324 325 # A null 'decorator', useful to make more readable code that needs to pick
325 326 # between different decorators based on OS or other conditions
@@ -53,6 +53,7 b' from IPython.utils.sysinfo import sys_info'
53 53
54 54 from IPython.testing import globalipapp
55 55 from IPython.testing.plugin.ipdoctest import IPythonDoctest
56 from IPython.external.decorators import KnownFailure
56 57
57 58 pjoin = path.join
58 59
@@ -357,7 +358,7 b' def run_iptest():'
357 358
358 359 # Construct list of plugins, omitting the existing doctest plugin, which
359 360 # ours replaces (and extends).
360 plugins = [IPythonDoctest(make_exclude())]
361 plugins = [IPythonDoctest(make_exclude()), KnownFailure()]
361 362 for p in nose.plugins.builtin.plugins:
362 363 plug = p()
363 364 if plug.name == 'doctest':
General Comments 0
You need to be logged in to leave comments. Login now