コード例 #1
0
def test_connection_file_real_path():
    """ Verify realpath is used when formatting connection file """
    with mock.patch('os.path.realpath') as patched_realpath:
        patched_realpath.return_value = 'foobar'
        km = KernelManager(connection_file=os.path.join(
                tempfile.gettempdir(), "kernel-test.json"),
                kernel_name='test_kernel')

        # KernelSpec and launch args have to be mocked as we don't have an actual kernel on disk
        km._kernel_spec = KernelSpec(resource_dir='test', 
            **{
                "argv": [
                    "python.exe",
                    "-m",
                    "test_kernel",
                    "-f",
                    "{connection_file}"
                ],
                "env": {},
                "display_name": "test_kernel",
                "language": "python",
                "metadata": {}
            })
        km._launch_args = {}
        cmds = km.format_kernel_cmd()
        assert cmds[4] is 'foobar'
コード例 #2
0
def start_new_kernel(startup_timeout=60, kernel_name='python', spykernel=False,
                     **kwargs):
    """Start a new kernel, and return its Manager and Client"""
    km = KernelManager(kernel_name=kernel_name)
    if spykernel:
        km._kernel_spec = SpyderKernelSpec()
    km.start_kernel(**kwargs)
    kc = km.client()
    kc.start_channels()
    try:
        kc.wait_for_ready(timeout=startup_timeout)
    except RuntimeError:
        kc.stop_channels()
        km.shutdown_kernel()
        raise

    return km, kc
コード例 #3
0
ファイル: test_mainwindow.py プロジェクト: 0xBADCA7/spyder
def start_new_kernel(startup_timeout=60, kernel_name='python', spykernel=False,
                     **kwargs):
    """Start a new kernel, and return its Manager and Client"""
    km = KernelManager(kernel_name=kernel_name)
    if spykernel:
        km._kernel_spec = SpyderKernelSpec()
    km.start_kernel(**kwargs)
    kc = km.client()
    kc.start_channels()
    try:
        kc.wait_for_ready(timeout=startup_timeout)
    except RuntimeError:
        kc.stop_channels()
        km.shutdown_kernel()
        raise

    return km, kc