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 | try: |
|
1 | try: | |
2 | from numpy.testing.decorators import * |
|
2 | from numpy.testing.decorators import * | |
|
3 | from numpy.testing.noseclasses import KnownFailure | |||
3 | except ImportError: |
|
4 | except ImportError: | |
4 | from _decorators import * |
|
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 | import warnings |
|
16 | import warnings | |
17 | import sys |
|
|||
18 |
|
17 | |||
19 | # IPython changes: make this work if numpy not available |
|
18 | # IPython changes: make this work if numpy not available | |
20 | # Original code: |
|
19 | # Original code: | |
@@ -26,6 +25,11 b' try:' | |||||
26 | except ImportError: |
|
25 | except ImportError: | |
27 | from _numpy_testing_utils import WarningManager, WarningMessage |
|
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 | # End IPython changes |
|
33 | # End IPython changes | |
30 |
|
34 | |||
31 | def slow(t): |
|
35 | def slow(t): | |
@@ -34,7 +38,7 b' def slow(t):' | |||||
34 |
|
38 | |||
35 | The exact definition of a slow test is obviously both subjective and |
|
39 | The exact definition of a slow test is obviously both subjective and | |
36 | hardware-dependent, but in general any individual test that requires more |
|
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 | thousands of tests, so even a second is significant). |
|
42 | thousands of tests, so even a second is significant). | |
39 |
|
43 | |||
40 | Parameters |
|
44 | Parameters | |
@@ -172,7 +176,6 b' def skipif(skip_condition, msg=None):' | |||||
172 |
|
176 | |||
173 | return skip_decorator |
|
177 | return skip_decorator | |
174 |
|
178 | |||
175 |
|
||||
176 | def knownfailureif(fail_condition, msg=None): |
|
179 | def knownfailureif(fail_condition, msg=None): | |
177 | """ |
|
180 | """ | |
178 | Make function raise KnownFailureTest exception if given condition is true. |
|
181 | Make function raise KnownFailureTest exception if given condition is true. | |
@@ -216,7 +219,6 b' def knownfailureif(fail_condition, msg=None):' | |||||
216 | # Local import to avoid a hard nose dependency and only incur the |
|
219 | # Local import to avoid a hard nose dependency and only incur the | |
217 | # import time overhead at actual test-time. |
|
220 | # import time overhead at actual test-time. | |
218 | import nose |
|
221 | import nose | |
219 | from noseclasses import KnownFailureTest |
|
|||
220 | def knownfailer(*args, **kwargs): |
|
222 | def knownfailer(*args, **kwargs): | |
221 | if fail_val(): |
|
223 | if fail_val(): | |
222 | raise KnownFailureTest, msg |
|
224 | raise KnownFailureTest, msg | |
@@ -255,7 +257,6 b' def deprecated(conditional=True):' | |||||
255 | # Local import to avoid a hard nose dependency and only incur the |
|
257 | # Local import to avoid a hard nose dependency and only incur the | |
256 | # import time overhead at actual test-time. |
|
258 | # import time overhead at actual test-time. | |
257 | import nose |
|
259 | import nose | |
258 | from noseclasses import KnownFailureTest |
|
|||
259 |
|
260 | |||
260 | def _deprecated_imp(*args, **kwargs): |
|
261 | def _deprecated_imp(*args, **kwargs): | |
261 | # Poor man's replacement for the with statement |
|
262 | # Poor man's replacement for the with statement |
@@ -1,14 +1,10 b'' | |||||
1 |
# IPython: modified copy of numpy.testing.utils, so |
|
1 | # IPython: modified copy of numpy.testing.utils, so | |
2 | # works without numpy being installed. |
|
2 | # IPython.external._decorators works without numpy being installed. | |
3 | """ |
|
3 | """ | |
4 | Utility function to facilitate testing. |
|
4 | Utility function to facilitate testing. | |
5 | """ |
|
5 | """ | |
6 |
|
6 | |||
7 | import os |
|
|||
8 | import sys |
|
7 | import sys | |
9 | import re |
|
|||
10 | import operator |
|
|||
11 | import types |
|
|||
12 | import warnings |
|
8 | import warnings | |
13 |
|
9 | |||
14 | # The following two classes are copied from python 2.6 warnings module (context |
|
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 | recognize it as such. This will make it easier to migrate away from Nose if |
|
24 | recognize it as such. This will make it easier to migrate away from Nose if | |
25 | we ever need/want to while maintaining very lightweight tests. |
|
25 | we ever need/want to while maintaining very lightweight tests. | |
26 |
|
26 | |||
27 |
NOTE: This file contains IPython-specific decorators |
|
27 | NOTE: This file contains IPython-specific decorators. Using the machinery in | |
28 | numpy.testing.decorators file, which we've copied verbatim. Any of our own |
|
28 | IPython.external.decorators, we import either numpy.testing.decorators if numpy is | |
29 | code will be added at the bottom if we end up extending this. |
|
29 | available, OR use equivalent code in IPython.external._decorators, which | |
|
30 | we've copied verbatim from numpy. | |||
30 |
|
31 | |||
31 | Authors |
|
32 | Authors | |
32 | ------- |
|
33 | ------- | |
@@ -319,7 +320,7 b' skipif_not_numpy = skipif(module_not_available(\'numpy\'),"This test requires nump' | |||||
319 |
|
320 | |||
320 | skipif_not_sympy = skipif(module_not_available('sympy'),"This test requires sympy") |
|
321 | skipif_not_sympy = skipif(module_not_available('sympy'),"This test requires sympy") | |
321 |
|
322 | |||
322 |
skip_known_failure = |
|
323 | skip_known_failure = knownfailureif(True,'This test is known to fail') | |
323 |
|
324 | |||
324 | # A null 'decorator', useful to make more readable code that needs to pick |
|
325 | # A null 'decorator', useful to make more readable code that needs to pick | |
325 | # between different decorators based on OS or other conditions |
|
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 | from IPython.testing import globalipapp |
|
54 | from IPython.testing import globalipapp | |
55 | from IPython.testing.plugin.ipdoctest import IPythonDoctest |
|
55 | from IPython.testing.plugin.ipdoctest import IPythonDoctest | |
|
56 | from IPython.external.decorators import KnownFailure | |||
56 |
|
57 | |||
57 | pjoin = path.join |
|
58 | pjoin = path.join | |
58 |
|
59 | |||
@@ -357,7 +358,7 b' def run_iptest():' | |||||
357 |
|
358 | |||
358 | # Construct list of plugins, omitting the existing doctest plugin, which |
|
359 | # Construct list of plugins, omitting the existing doctest plugin, which | |
359 | # ours replaces (and extends). |
|
360 | # ours replaces (and extends). | |
360 | plugins = [IPythonDoctest(make_exclude())] |
|
361 | plugins = [IPythonDoctest(make_exclude()), KnownFailure()] | |
361 | for p in nose.plugins.builtin.plugins: |
|
362 | for p in nose.plugins.builtin.plugins: | |
362 | plug = p() |
|
363 | plug = p() | |
363 | if plug.name == 'doctest': |
|
364 | if plug.name == 'doctest': |
General Comments 0
You need to be logged in to leave comments.
Login now