##// END OF EJS Templates
add ShimWarning for shimmed imports...
Min RK -
Show More
@@ -0,0 +1,15 b''
1 import sys
2 import warnings
3
4 import nose.tools as nt
5
6 from IPython.utils.capture import capture_output
7 from IPython.utils.shimmodule import ShimWarning
8
9 def test_shim_warning():
10 sys.modules.pop('IPython.config', None)
11 with warnings.catch_warnings(record=True) as w:
12 warnings.simplefilter("always")
13 import IPython.config
14 assert len(w) == 1
15 assert issubclass(w[-1].category, ShimWarning)
@@ -7,10 +7,11 b' Shim to maintain backwards compatibility with old IPython.config imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11
10 warn("The `IPython.config` package has been deprecated. "
12 warn("The `IPython.config` package has been deprecated. "
11 "You should import from traitlets.config instead.")
13 "You should import from traitlets.config instead.", ShimWarning)
12
14
13 from IPython.utils.shimmodule import ShimModule
14
15
15 # Unconditionally insert the shim into sys.modules so that further import calls
16 # Unconditionally insert the shim into sys.modules so that further import calls
16 # trigger the custom attribute access above
17 # trigger the custom attribute access above
@@ -15,10 +15,10 b' working, though a warning will be printed.'
15 import sys
15 import sys
16 from warnings import warn
16 from warnings import warn
17
17
18 warn("The top-level `frontend` package has been deprecated. "
18 from IPython.utils.shimmodule import ShimModule, ShimWarning
19 "All its subpackages have been moved to the top `IPython` level.")
20
19
21 from IPython.utils.shimmodule import ShimModule
20 warn("The top-level `frontend` package has been deprecated. "
21 "All its subpackages have been moved to the top `IPython` level.", ShimWarning)
22
22
23 # Unconditionally insert the shim into sys.modules so that further import calls
23 # Unconditionally insert the shim into sys.modules so that further import calls
24 # trigger the custom attribute access above
24 # trigger the custom attribute access above
@@ -7,11 +7,11 b' Shim to maintain backwards compatibility with old IPython.html imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11
10 warn("The `IPython.html` package has been deprecated. "
12 warn("The `IPython.html` package has been deprecated. "
11 "You should import from `notebook` instead. "
13 "You should import from `notebook` instead. "
12 "`IPython.html.widgets` has moved to `ipywidgets`.")
14 "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)
13
14 from IPython.utils.shimmodule import ShimModule
15
15
16 _widgets = sys.modules['IPython.html.widgets'] = ShimModule(
16 _widgets = sys.modules['IPython.html.widgets'] = ShimModule(
17 src='IPython.html.widgets', mirror='ipywidgets')
17 src='IPython.html.widgets', mirror='ipywidgets')
@@ -7,11 +7,11 b' Shim to maintain backwards compatibility with old IPython.kernel imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 warn("The `IPython.kernel` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11 "You should import from ipykernel or jupyter_client instead.")
12
11
12 warn("The `IPython.kernel` package has been deprecated. "
13 "You should import from ipykernel or jupyter_client instead.", ShimWarning)
13
14
14 from IPython.utils.shimmodule import ShimModule
15
15
16 # zmq subdir is gone
16 # zmq subdir is gone
17 sys.modules['IPython.kernel.zmq.session'] = ShimModule(
17 sys.modules['IPython.kernel.zmq.session'] = ShimModule(
@@ -7,10 +7,10 b' Shim to maintain backwards compatibility with old IPython.nbconvert imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 warn("The `IPython.nbconvert` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11 "You should import from ipython_nbconvert instead.")
12
11
13 from IPython.utils.shimmodule import ShimModule
12 warn("The `IPython.nbconvert` package has been deprecated. "
13 "You should import from ipython_nbconvert instead.", ShimWarning)
14
14
15 # Unconditionally insert the shim into sys.modules so that further import calls
15 # Unconditionally insert the shim into sys.modules so that further import calls
16 # trigger the custom attribute access above
16 # trigger the custom attribute access above
@@ -7,10 +7,10 b' Shim to maintain backwards compatibility with old IPython.nbformat imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 warn("The `IPython.nbformat` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11 "You should import from nbformat instead.")
12
11
13 from IPython.utils.shimmodule import ShimModule
12 warn("The `IPython.nbformat` package has been deprecated. "
13 "You should import from nbformat instead.", ShimWarning)
14
14
15 # Unconditionally insert the shim into sys.modules so that further import calls
15 # Unconditionally insert the shim into sys.modules so that further import calls
16 # trigger the custom attribute access above
16 # trigger the custom attribute access above
@@ -7,10 +7,10 b' Shim to maintain backwards compatibility with old IPython.parallel imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 warn("The `IPython.parallel` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11 "You should import from ipyparallel instead.")
12
11
13 from IPython.utils.shimmodule import ShimModule
12 warn("The `IPython.parallel` package has been deprecated. "
13 "You should import from ipyparallel instead.", ShimWarning)
14
14
15 # Unconditionally insert the shim into sys.modules so that further import calls
15 # Unconditionally insert the shim into sys.modules so that further import calls
16 # trigger the custom attribute access above
16 # trigger the custom attribute access above
@@ -7,10 +7,10 b' Shim to maintain backwards compatibility with old IPython.qt imports.'
7 import sys
7 import sys
8 from warnings import warn
8 from warnings import warn
9
9
10 warn("The `IPython.qt` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
11 "You should import from qtconsole instead.")
12
11
13 from IPython.utils.shimmodule import ShimModule
12 warn("The `IPython.qt` package has been deprecated. "
13 "You should import from qtconsole instead.", ShimWarning)
14
14
15 # Unconditionally insert the shim into sys.modules so that further import calls
15 # Unconditionally insert the shim into sys.modules so that further import calls
16 # trigger the custom attribute access above
16 # trigger the custom attribute access above
@@ -4,15 +4,13 b' Shim to maintain backwards compatibility with old IPython.terminal.console impor'
4 # Copyright (c) IPython Development Team.
4 # Copyright (c) IPython Development Team.
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6
6
7 from __future__ import print_function
8
9 import sys
7 import sys
10 from warnings import warn
8 from warnings import warn
11
9
12 warn("The `IPython.terminal.console` package has been deprecated. "
10 from IPython.utils.shimmodule import ShimModule, ShimWarning
13 "You should import from jupyter_console instead.")
14
11
15 from IPython.utils.shimmodule import ShimModule
12 warn("The `IPython.terminal.console` package has been deprecated. "
13 "You should import from jupyter_console instead.", ShimWarning)
16
14
17 # Unconditionally insert the shim into sys.modules so that further import calls
15 # Unconditionally insert the shim into sys.modules so that further import calls
18 # trigger the custom attribute access above
16 # trigger the custom attribute access above
@@ -8,6 +8,8 b' import types'
8
8
9 from .importstring import import_item
9 from .importstring import import_item
10
10
11 class ShimWarning(Warning):
12 """A warning to show when a module has moved, and a shim is in its place."""
11
13
12 class ShimImporter(object):
14 class ShimImporter(object):
13 """Import hook for a shim.
15 """Import hook for a shim.
General Comments 0
You need to be logged in to leave comments. Login now