From d18872e9d990d32f6b80e4a0b65e27e62e2c2199 2013-01-30 04:44:33 From: MinRK Date: 2013-01-30 04:44:33 Subject: [PATCH] define and test IPython.kernel public API --- diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 3b4edb1..6c42bae 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -61,6 +61,7 @@ from IPython.config.application import catch_config_error, boolean_flag from IPython.core.application import BaseIPythonApplication from IPython.core.profiledir import ProfileDir from IPython.frontend.consoleapp import IPythonConsoleApp +from IPython.kernel import swallow_argv from IPython.kernel.zmq.session import Session, default_secure from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell from IPython.kernel.zmq.kernelapp import ( @@ -70,7 +71,6 @@ from IPython.kernel.zmq.kernelapp import ( ) from IPython.utils.importstring import import_item from IPython.utils.localinterfaces import LOCALHOST -from IPython.kernel import swallow_argv from IPython.utils.traitlets import ( Dict, Unicode, Integer, List, Enum, Bool, DottedObjectName diff --git a/IPython/kernel/__init__.py b/IPython/kernel/__init__.py index 38b24ec..a911eb1 100644 --- a/IPython/kernel/__init__.py +++ b/IPython/kernel/__init__.py @@ -1,5 +1,7 @@ -"""IPython kernel bases and utilities""" +"""IPython kernels and associated utilities""" from .connect import * from .launcher import * -from .kernelmanagerabc import * +from .kernelmanager import KernelManager +from .blockingkernelmanager import BlockingKernelManager +from .multikernelmanager import MultiKernelManager diff --git a/IPython/kernel/connect.py b/IPython/kernel/connect.py index 98f3fc8..9a55d20 100644 --- a/IPython/kernel/connect.py +++ b/IPython/kernel/connect.py @@ -337,3 +337,11 @@ def tunnel_to_kernel(connection_info, sshserver, sshkey=None): return tuple(lports) +__all__ = [ + 'write_connection_file', + 'get_connection_file', + 'find_connection_file', + 'get_connection_info', + 'connect_qtconsole', + 'tunnel_to_kernel', +] \ No newline at end of file diff --git a/IPython/kernel/inprocess/kernelmanager.py b/IPython/kernel/inprocess/kernelmanager.py index 1848ab6..b31f271 100644 --- a/IPython/kernel/inprocess/kernelmanager.py +++ b/IPython/kernel/inprocess/kernelmanager.py @@ -14,7 +14,7 @@ # Local imports. from IPython.config.configurable import Configurable from IPython.utils.traitlets import Any, Instance, Type -from IPython.kernel import ( +from IPython.kernel.kernelmanagerabc import ( ShellChannelABC, IOPubChannelABC, HBChannelABC, StdInChannelABC, KernelManagerABC diff --git a/IPython/kernel/kernelmanager.py b/IPython/kernel/kernelmanager.py index daa6046..6c179c8 100644 --- a/IPython/kernel/kernelmanager.py +++ b/IPython/kernel/kernelmanager.py @@ -47,8 +47,8 @@ from IPython.kernel import ( make_ipkernel_cmd, launch_kernel, ) -from IPython.kernel.zmq.session import Session -from IPython.kernel import ( +from .zmq.session import Session +from .kernelmanagerabc import ( ShellChannelABC, IOPubChannelABC, HBChannelABC, StdInChannelABC, KernelManagerABC diff --git a/IPython/kernel/launcher.py b/IPython/kernel/launcher.py index 4e40394..4ebf4a6 100644 --- a/IPython/kernel/launcher.py +++ b/IPython/kernel/launcher.py @@ -251,3 +251,8 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, return proc +__all__ = [ + 'swallow_argv', + 'make_ipkernel_cmd', + 'launch_kernel', +] \ No newline at end of file diff --git a/IPython/kernel/tests/test_kernelmanager.py b/IPython/kernel/tests/test_kernelmanager.py index 44fbabf..0d70da8 100644 --- a/IPython/kernel/tests/test_kernelmanager.py +++ b/IPython/kernel/tests/test_kernelmanager.py @@ -42,7 +42,7 @@ class TestKernelManager(TestCase): self._run_lifecycle(km) @dec.skip_win32 - def testipc_lifecycle(self): + def test_ipc_lifecycle(self): km = self._get_ipc_km() self._run_lifecycle(km) diff --git a/IPython/kernel/tests/test_public_api.py b/IPython/kernel/tests/test_public_api.py new file mode 100644 index 0000000..aca6cca --- /dev/null +++ b/IPython/kernel/tests/test_public_api.py @@ -0,0 +1,41 @@ +"""Test the IPython.kernel public API + +Authors +------- +* MinRK +""" +#----------------------------------------------------------------------------- +# Copyright (c) 2013, the IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +import nose.tools as nt + +from IPython.testing import decorators as dec + +from IPython.kernel import launcher, connect +from IPython import kernel + +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- + +@dec.parametric +def test_kms(): + for base in ("", "Blocking", "Multi"): + KM = base + "KernelManager" + yield nt.assert_true(KM in dir(kernel), KM) + +@dec.parametric +def test_launcher(): + for name in launcher.__all__: + yield nt.assert_true(name in dir(kernel), name) + +@dec.parametric +def test_connect(): + for name in connect.__all__: + yield nt.assert_true(name in dir(kernel), name) +