Skip to content

Commit dfbc5b5

Browse files
authored
Parse list value for terminado_settings (#949)
1 parent 4a34e6a commit dfbc5b5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

jupyter_server/serverapp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
TraitError,
7676
Type,
7777
Unicode,
78+
Union,
7879
default,
7980
observe,
8081
validate,
@@ -1318,6 +1319,7 @@ def _default_allow_remote(self):
13181319
),
13191320
)
13201321
terminado_settings = Dict(
1322+
Union([List(), Unicode()]),
13211323
config=True,
13221324
help=_i18n('Supply overrides for terminado. Currently only supports "shell_command".'),
13231325
)

tests/test_terminal.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import json
33
import os
4+
import shlex
45
import shutil
56
import sys
67

@@ -258,3 +259,19 @@ async def test_culling(jp_server_config, jp_fetch):
258259
await asyncio.sleep(1)
259260

260261
assert culled
262+
263+
264+
@pytest.mark.parametrize(
265+
"terminado_settings,expected_shell,min_traitlets",
266+
[
267+
("shell_command=\"['/path/to/shell', '-l']\"", ["/path/to/shell", "-l"], "5.4"),
268+
('shell_command="/string/path/to/shell -l"', ["/string/path/to/shell", "-l"], "5.1"),
269+
],
270+
)
271+
def test_shell_command_override(
272+
terminado_settings, expected_shell, min_traitlets, jp_configurable_serverapp
273+
):
274+
pytest.importorskip("traitlets", minversion=min_traitlets)
275+
argv = shlex.split(f"--ServerApp.terminado_settings={terminado_settings}")
276+
app = jp_configurable_serverapp(argv=argv)
277+
assert app.web_app.settings["terminal_manager"].shell_command == expected_shell

0 commit comments

Comments
 (0)