diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index a499a56..49572a7 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -64,7 +64,7 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None): parameter. """ warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1", - DeprecationWarning) + DeprecationWarning, stacklevel=2) if et==bdb.BdbQuit: print('Exiting Debugger.') elif excepthook is not None: @@ -77,7 +77,7 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None): def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): warnings.warn( "`BdbQuit_IPython_excepthook` is deprecated since version 5.1", - DeprecationWarning) + DeprecationWarning, stacklevel=2) print('Exiting Debugger.') @@ -129,7 +129,7 @@ class Tracer(object): """ warnings.warn("`Tracer` is deprecated since version 5.1, directly use " "`IPython.core.debugger.Pdb.set_trace()`", - DeprecationWarning) + DeprecationWarning, stacklevel=2) ip = get_ipython() if ip is None: diff --git a/IPython/core/excolors.py b/IPython/core/excolors.py index 279924b..d979a71 100644 --- a/IPython/core/excolors.py +++ b/IPython/core/excolors.py @@ -165,7 +165,8 @@ class Deprec(object): def __getattr__(self, name): val = getattr(self.wrapped, name) - warnings.warn("Using ExceptionColors global is deprecated and will be removed in IPython 6.0", DeprecationWarning) + warnings.warn("Using ExceptionColors global is deprecated and will be removed in IPython 6.0", + DeprecationWarning, stacklevel=2) # using getattr after warnings break ipydoctest in weird way for 3.5 return val diff --git a/IPython/lib/inputhook.py b/IPython/lib/inputhook.py index 98d8c2c..e6e8f2d 100644 --- a/IPython/lib/inputhook.py +++ b/IPython/lib/inputhook.py @@ -658,7 +658,9 @@ guis = inputhook_manager.guihooks def _deprecated_disable(): - warn("This function is deprecated since IPython 4.0 use disable_gui() instead", DeprecationWarning) + warn("This function is deprecated since IPython 4.0 use disable_gui() instead", + DeprecationWarning, stacklevel=2) inputhook_manager.disable_gui() + disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \ disable_pyglet = disable_osx = _deprecated_disable diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index 087555d..c9807ce 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -67,7 +67,7 @@ def as_unittest(func): # Utility functions -def apply_wrapper(wrapper,func): +def apply_wrapper(wrapper, func): """Apply a wrapper to a function for decoration. This mixes Michele Simionato's decorator tool with nose's make_decorator, @@ -76,14 +76,14 @@ def apply_wrapper(wrapper,func): This will ensure that wrapped functions can still be well introspected via IPython, for example. """ - warnings.warn("The function `apply_wrapper` is deprecated and might be removed in IPython 5.0", DeprecationWarning) - + warnings.warn("The function `apply_wrapper` is deprecated since IPython 4.0", + DeprecationWarning, stacklevel=2) import nose.tools return decorator(wrapper,nose.tools.make_decorator(func)(wrapper)) -def make_label_dec(label,ds=None): +def make_label_dec(label, ds=None): """Factory function to create a decorator that applies one or more labels. Parameters @@ -128,7 +128,8 @@ def make_label_dec(label,ds=None): True """ - warnings.warn("The function `make_label_dec` is deprecated and might be removed in IPython 5.0", DeprecationWarning) + warnings.warn("The function `make_label_dec` is deprecated since IPython 4.0", + DeprecationWarning, stacklevel=2) if isinstance(label, string_types): labels = [label] else: @@ -284,7 +285,8 @@ def decorated_dummy(dec, name): import IPython.testing.decorators as dec setup = dec.decorated_dummy(dec.skip_if_no_x11, __name__) """ - warnings.warn("The function `make_label_dec` is deprecated and might be removed in IPython 5.0", DeprecationWarning) + warnings.warn("The function `decorated_dummy` is deprecated since IPython 4.0", + DeprecationWarning, stacklevel=2) dummy = lambda: None dummy.__name__ = name return dec(dummy) @@ -317,7 +319,8 @@ skip_if_no_x11 = skipif(_x11_skip_cond, _x11_skip_msg) # not a decorator itself, returns a dummy function to be used as setup def skip_file_no_x11(name): - warnings.warn("The function `skip_file_no_x11` is deprecated and might be removed in IPython 5.0", DeprecationWarning) + warnings.warn("The function `skip_file_no_x11` is deprecated since IPython 4.0", + DeprecationWarning, stacklevel=2) return decorated_dummy(skip_if_no_x11, name) if _x11_skip_cond else None # Other skip decorators @@ -372,7 +375,8 @@ def onlyif_any_cmd_exists(*commands): """ Decorator to skip test unless at least one of `commands` is found. """ - warnings.warn("The function `onlyif_any_cmd_exists` is deprecated and might be removed in IPython 5.0", DeprecationWarning) + warnings.warn("The function `onlyif_any_cmd_exists` is deprecated since IPython 4.0", + DeprecationWarning, stacklevel=2) for cmd in commands: if which(cmd): return null_deco diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index b2f19a4..4018264 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -50,6 +50,16 @@ if sys.version_info > (3,0): warnings.filterwarnings('error', message=".*{'config': True}.*", category=DeprecationWarning, module='IPy.*') warnings.filterwarnings('default', message='.*', category=Warning, module='IPy.*') +warnings.filterwarnings('error', message='.*apply_wrapper.*', category=DeprecationWarning, module='.*') +warnings.filterwarnings('error', message='.*make_label_dec', category=DeprecationWarning, module='.*') +warnings.filterwarnings('error', message='.*decorated_dummy.*', category=DeprecationWarning, module='.*') +warnings.filterwarnings('error', message='.*skip_file_no_x11.*', category=DeprecationWarning, module='.*') +warnings.filterwarnings('error', message='.*onlyif_any_cmd_exists.*', category=DeprecationWarning, module='.*') + +warnings.filterwarnings('error', message='.*disable_gui.*', category=DeprecationWarning, module='.*') + +warnings.filterwarnings('error', message='.*ExceptionColors global is deprecated.*', category=DeprecationWarning, module='.*') + if version_info < (6,): # nose.tools renames all things from `camelCase` to `snake_case` which raise an # warning with the runner they also import from standard import library. (as of Dec 2015)