Debian Codegraph @

tests/test_consoleapp.py

raw
1 """Tests for the JupyterConsoleApp"""
2
3 # Copyright (c) Jupyter Development Team.
4 # Distributed under the terms of the Modified BSD License.
5 import os
6
7 import pytest
8 from jupyter_core.application import JupyterApp
9
10 from jupyter_client.consoleapp import JupyterConsoleApp
11 from jupyter_client.manager import start_new_kernel
12
13
14 class MockConsoleApp(JupyterConsoleApp, JupyterApp): # type:ignore
15 pass
16
17
18 def test_console_app_no_existing():
19 app = MockConsoleApp()
20 app.initialize([])
21
22
23 def test_console_app_existing(tmp_path):
24 km, kc = start_new_kernel()
25 cf = kc.connection_file
26 app = MockConsoleApp(connection_file=cf, existing=cf)
27 app.initialize([])
28 kc.stop_channels()
29 km.shutdown_kernel()
30
31
32 def test_console_app_ssh(tmp_path):
33 km, kc = start_new_kernel()
34 cf = kc.connection_file
35 os.chdir(tmp_path)
36 app = MockConsoleApp(
37 connection_file=cf, existing=cf, sshserver="does_not_exist", sshkey="test_console_app"
38 )
39 with pytest.raises(SystemExit):
40 app.initialize([])
41 kc.stop_channels()
42 km.shutdown_kernel()