You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/jupyter_client/tests/test_manager.py

39 lines
1.3 KiB

"""Tests for KernelManager"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from jupyter_client.kernelspec import KernelSpec
from unittest import mock
from jupyter_client.manager import KernelManager
import os
import tempfile
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'