def load(shell): """ Load all IPython ``%magic`` functions from :mod:`morepy.magic`. :param shell: The ``IPython`` shell instance """ load_magic_modules('magic', package=__name__, shell=shell)
def test_load_magic_modules_with_invalid_keywords(magic_module__name__, shell): """ Test :func:`moreshell.load_magic_modules` raises ``TypeError``. When called with invalid keyword arguments """ assert 'test_moreshell' not in shell.magics_manager.magics['line'] with pytest.raises(TypeError, match=r" unexpected keyword argument\(s\) 'invalid'$"): load_magic_modules(magic_module__name__, shell=shell, invalid=True)
def test_load_magic_modules_with_package__name__(magic_module__name__, shell): """ Test that :func:`moreshell.load_magic_modules` registers all ``%magic``. That it registers all ``%magic`` and cell ``%%magic`` created in a :class:`moreshell.IPython_magic_module`-wrapped module to the IPython shell's ``.magics_manager`` Using relative module name and the ``package=`` keyword argument set to the parent package name """ assert 'test_moreshell' not in shell.magics_manager.magics['line'] pkgname, modname = magic_module__name__.rsplit('.', 1) modules = load_magic_modules(modname, package=pkgname, shell=shell) from moreshell.test import magic_module assert sys.modules[magic_module__name__] is magic_module assert modules == [magic_module] assert shell.magics_manager.magics['line']['test_moreshell'] is ( sys.modules[magic_module__name__].test_moreshell)
def test_load_magic_modules(magic_module__name__, shell): """ Test that :func:`moreshell.load_magic_modules` registers all ``%magic``. That it registers all ``%magic`` and cell ``%%magic`` created in a :class:`moreshell.IPython_magic_module`-wrapped module to the IPython shell's ``.magics_manager`` Using full module name and therefore omitting the ``package=`` argument """ assert 'test_moreshell' not in shell.magics_manager.magics['line'] # HACK: Python 3.5 on Travis CI strangely reports missing coverage modules = load_magic_modules( # pragma: no cover magic_module__name__, shell=shell) from moreshell.test import magic_module # pragma: no cover assert ( # pragma: no cover sys.modules[magic_module__name__] is magic_module) assert modules == [magic_module] # pragma: no cover assert shell.magics_manager.magics['line']['test_moreshell'] is ( sys.modules[magic_module__name__].test_moreshell)
def load_ipython_extension(shell): # pragma: no cover """Provide the handler for ``%load_ext moreshell.test`` in IPython.""" from moreshell import load_magic_modules load_magic_modules('magic_module', package=__name__, shell=shell)