@@ -61,93 +61,6 @@ def test(self):
6161
6262# Utility functions
6363
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-
15164
15265def skip_iptest_but_not_pytest (f ):
15366 """
@@ -234,20 +147,6 @@ def module_not_available(module):
234147 return mod_not_avail
235148
236149
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-
251150#-----------------------------------------------------------------------------
252151# Decorators for public use
253152
@@ -279,12 +178,6 @@ def decorated_dummy(dec, name):
279178skip_win32_py38 = skipif (sys .version_info > (3 ,8 ) and os .name == 'nt' )
280179
281180
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-
288181# Other skip decorators
289182
290183# generic skip without module
@@ -328,15 +221,3 @@ def onlyif_cmds_exist(*commands):
328221
329222 return pytest .mark .skip (reason = reason )
330223 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 ))
0 commit comments