##// END OF EJS Templates
Merge pull request #10320 from Carreau/cleanup-unused...
Paul Ivanov -
r23396:d036e1ba merge
parent child Browse files
Show More
@@ -17,10 +17,6 b' import warnings'
17
17
18 # IPython changes: make this work if numpy not available
18 # IPython changes: make this work if numpy not available
19 # Original code:
19 # Original code:
20 #from numpy.testing.utils import \
21 # WarningManager, WarningMessage
22 # Our version:
23 from ._numpy_testing_utils import WarningManager
24 try:
20 try:
25 from ._numpy_testing_noseclasses import KnownFailureTest
21 from ._numpy_testing_noseclasses import KnownFailureTest
26 except:
22 except:
@@ -28,73 +24,6 b' except:'
28
24
29 # End IPython changes
25 # End IPython changes
30
26
31 def slow(t):
32 """
33 Label a test as 'slow'.
34
35 The exact definition of a slow test is obviously both subjective and
36 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 consists of
38 thousands of tests, so even a second is significant).
39
40 Parameters
41 ----------
42 t : callable
43 The test to label as slow.
44
45 Returns
46 -------
47 t : callable
48 The decorated test `t`.
49
50 Examples
51 --------
52 The `numpy.testing` module includes ``import decorators as dec``.
53 A test can be decorated as slow like this::
54
55 from numpy.testing import *
56
57 @dec.slow
58 def test_big(self):
59 print 'Big, slow test'
60
61 """
62
63 t.slow = True
64 return t
65
66 def setastest(tf=True):
67 """
68 Signals to nose that this function is or is not a test.
69
70 Parameters
71 ----------
72 tf : bool
73 If True, specifies that the decorated callable is a test.
74 If False, specifies that the decorated callable is not a test.
75 Default is True.
76
77 Notes
78 -----
79 This decorator can't use the nose namespace, because it can be
80 called from a non-test module. See also ``istest`` and ``nottest`` in
81 ``nose.tools``.
82
83 Examples
84 --------
85 `setastest` can be used in the following way::
86
87 from numpy.testing.decorators import setastest
88
89 @setastest(False)
90 def func_with_test_in_name(arg1, arg2):
91 pass
92
93 """
94 def set_test(t):
95 t.__test__ = tf
96 return t
97 return set_test
98
27
99 def skipif(skip_condition, msg=None):
28 def skipif(skip_condition, msg=None):
100 """
29 """
@@ -224,58 +153,3 b' def knownfailureif(fail_condition, msg=None):'
224
153
225 return knownfail_decorator
154 return knownfail_decorator
226
155
227 def deprecated(conditional=True):
228 """
229 Filter deprecation warnings while running the test suite.
230
231 This decorator can be used to filter DeprecationWarning's, to avoid
232 printing them during the test suite run, while checking that the test
233 actually raises a DeprecationWarning.
234
235 Parameters
236 ----------
237 conditional : bool or callable, optional
238 Flag to determine whether to mark test as deprecated or not. If the
239 condition is a callable, it is used at runtime to dynamically make the
240 decision. Default is True.
241
242 Returns
243 -------
244 decorator : function
245 The `deprecated` decorator itself.
246
247 Notes
248 -----
249 .. versionadded:: 1.4.0
250
251 """
252 def deprecate_decorator(f):
253 # Local import to avoid a hard nose dependency and only incur the
254 # import time overhead at actual test-time.
255 import nose
256
257 def _deprecated_imp(*args, **kwargs):
258 # Poor man's replacement for the with statement
259 ctx = WarningManager(record=True)
260 l = ctx.__enter__()
261 warnings.simplefilter('always')
262 try:
263 f(*args, **kwargs)
264 if not len(l) > 0:
265 raise AssertionError("No warning raised when calling %s"
266 % f.__name__)
267 if not l[0].category is DeprecationWarning:
268 raise AssertionError("First warning for %s is not a " \
269 "DeprecationWarning( is %s)" % (f.__name__, l[0]))
270 finally:
271 ctx.__exit__()
272
273 if callable(conditional):
274 cond = conditional()
275 else:
276 cond = conditional
277 if cond:
278 return nose.tools.make_decorator(f)(_deprecated_imp)
279 else:
280 return f
281 return deprecate_decorator
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now