Skip to content

Commit 6b2a7b2

Browse files
committed
added per-key traitlets and test for extra_env
1 parent 56e2478 commit 6b2a7b2

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

jupyter_server/serverapp.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,10 +1488,18 @@ def _default_allow_remote(self) -> bool:
14881488
"""
14891489
),
14901490
)
1491+
14911492
terminado_settings = Dict(
1492-
Union([List(), Unicode()]),
1493+
per_key_traits={
1494+
"shell_command": Union(
1495+
[List(), Unicode()], help="The shell command to execute in the terminal."
1496+
),
1497+
"extra_env": Dict(
1498+
Unicode(), help="Extra environment variables to set in the terminal."
1499+
),
1500+
},
14931501
config=True,
1494-
help=_i18n('Supply overrides for terminado. Currently only supports "shell_command".'),
1502+
help=_i18n("Supply overrides for terminado."),
14951503
)
14961504

14971505
cookie_options = Dict(

tests/test_terminal.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ def test_shell_command_override(
297297
assert app.web_app.settings["terminal_manager"].shell_command == expected_shell
298298

299299

300+
def test_terminal_extra_env_override(jp_configurable_serverapp):
301+
config = Config({"ServerApp": {"terminado_settings": {"extra_env": {"PS1": "jupyter> "}}}})
302+
303+
app = jp_configurable_serverapp(config=config)
304+
terminado_settings = getattr(app, "terminado_settings", {})
305+
306+
assert "extra_env" in terminado_settings
307+
assert "PS1" in terminado_settings["extra_env"]
308+
assert terminado_settings["extra_env"]["PS1"] == "jupyter> "
309+
310+
300311
def test_importing_shims():
301312
with warnings.catch_warnings():
302313
warnings.simplefilter("ignore")

0 commit comments

Comments
 (0)