##// END OF EJS Templates
Remove bunch of deprecated and unused testing decorators
Nikita Kniazev -
Show More
@@ -61,93 +61,6 b' def as_unittest(func):'
61
61
62 # Utility functions
62 # Utility functions
63
63
64 def apply_wrapper(wrapper, func):
65 """Apply a wrapper to a function for decoration.
66
67 This mixes Michele Simionato's decorator tool with nose's make_decorator,
68 to apply a wrapper in a decorator so that all nose attributes, as well as
69 function signature and other properties, survive the decoration cleanly.
70 This will ensure that wrapped functions can still be well introspected via
71 IPython, for example.
72 """
73 warnings.warn("The function `apply_wrapper` is deprecated since IPython 4.0",
74 DeprecationWarning, stacklevel=2)
75 import nose.tools
76
77 return decorator(wrapper,nose.tools.make_decorator(func)(wrapper))
78
79
80 def make_label_dec(label, ds=None):
81 """Factory function to create a decorator that applies one or more labels.
82
83 Parameters
84 ----------
85 label : string or sequence
86 One or more labels that will be applied by the decorator to the functions
87 it decorates. Labels are attributes of the decorated function with their
88 value set to True.
89
90 ds : string
91 An optional docstring for the resulting decorator. If not given, a
92 default docstring is auto-generated.
93
94 Returns
95 -------
96 A decorator.
97
98 Examples
99 --------
100
101 A simple labeling decorator:
102
103 >>> slow = make_label_dec('slow')
104 >>> slow.__doc__
105 "Labels a test as 'slow'."
106
107 And one that uses multiple labels and a custom docstring:
108
109 >>> rare = make_label_dec(['slow','hard'],
110 ... "Mix labels 'slow' and 'hard' for rare tests.")
111 >>> rare.__doc__
112 "Mix labels 'slow' and 'hard' for rare tests."
113
114 Now, let's test using this one:
115 >>> @rare
116 ... def f(): pass
117 ...
118 >>>
119 >>> f.slow
120 True
121 >>> f.hard
122 True
123 """
124
125 warnings.warn("The function `make_label_dec` is deprecated since IPython 4.0",
126 DeprecationWarning, stacklevel=2)
127 if isinstance(label, str):
128 labels = [label]
129 else:
130 labels = label
131
132 # Validate that the given label(s) are OK for use in setattr() by doing a
133 # dry run on a dummy function.
134 tmp = lambda : None
135 for label in labels:
136 setattr(tmp,label,True)
137
138 # This is the actual decorator we'll return
139 def decor(f):
140 for label in labels:
141 setattr(f,label,True)
142 return f
143
144 # Apply the user's docstring, or autogenerate a basic one
145 if ds is None:
146 ds = "Labels a test as %r." % label
147 decor.__doc__ = ds
148
149 return decor
150
151
64
152 def skip_iptest_but_not_pytest(f):
65 def skip_iptest_but_not_pytest(f):
153 """
66 """
@@ -234,20 +147,6 b' def module_not_available(module):'
234 return mod_not_avail
147 return mod_not_avail
235
148
236
149
237 def decorated_dummy(dec, name):
238 """Return a dummy function decorated with dec, with the given name.
239
240 Examples
241 --------
242 import IPython.testing.decorators as dec
243 setup = dec.decorated_dummy(dec.skip_if_no_x11, __name__)
244 """
245 warnings.warn("The function `decorated_dummy` is deprecated since IPython 4.0",
246 DeprecationWarning, stacklevel=2)
247 dummy = lambda: None
248 dummy.__name__ = name
249 return dec(dummy)
250
251 #-----------------------------------------------------------------------------
150 #-----------------------------------------------------------------------------
252 # Decorators for public use
151 # Decorators for public use
253
152
@@ -279,12 +178,6 b' skip_if_no_x11 = skipif(_x11_skip_cond, _x11_skip_msg)'
279 skip_win32_py38 = skipif(sys.version_info > (3,8) and os.name == 'nt')
178 skip_win32_py38 = skipif(sys.version_info > (3,8) and os.name == 'nt')
280
179
281
180
282 # not a decorator itself, returns a dummy function to be used as setup
283 def skip_file_no_x11(name):
284 warnings.warn("The function `skip_file_no_x11` is deprecated since IPython 4.0",
285 DeprecationWarning, stacklevel=2)
286 return decorated_dummy(skip_if_no_x11, name) if _x11_skip_cond else None
287
288 # Other skip decorators
181 # Other skip decorators
289
182
290 # generic skip without module
183 # generic skip without module
@@ -328,15 +221,3 b' def onlyif_cmds_exist(*commands):'
328
221
329 return pytest.mark.skip(reason=reason)
222 return pytest.mark.skip(reason=reason)
330 return null_deco
223 return null_deco
331
332 def onlyif_any_cmd_exists(*commands):
333 """
334 Decorator to skip test unless at least one of `commands` is found.
335 """
336 warnings.warn("The function `onlyif_any_cmd_exists` is deprecated since IPython 4.0",
337 DeprecationWarning, stacklevel=2)
338 for cmd in commands:
339 if shutil.which(cmd):
340 return null_deco
341 return skip("This test runs only if one of the commands {0} "
342 "is installed".format(commands))
General Comments 0
You need to be logged in to leave comments. Login now