Skip to content

Commit 379f760

Browse files
committed
Allow ServerApp.no_browser_open_file option to be set via config / cli args
1 parent c67a46b commit 379f760

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

jupyter_server/serverapp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,11 @@ def _default_info_file(self) -> str:
17551755
return os.path.join(self.runtime_dir, info_file)
17561756

17571757
no_browser_open_file = Bool(
1758-
False, help="If True, do not write redirect HTML file disk, or show in messages."
1758+
False,
1759+
config=True,
1760+
help=_i18n(
1761+
"If True, do not write redirect HTML file disk, or show in startup output messages."
1762+
),
17591763
)
17601764

17611765
browser_open_file = Unicode()

tests/test_serverapp.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def test_running_server_info(jp_serverapp):
607607

608608

609609
@pytest.mark.parametrize("should_exist", [True, False])
610-
async def test_browser_open_files(jp_configurable_serverapp, should_exist, caplog):
610+
async def test_no_browser_open_file(jp_configurable_serverapp, should_exist, caplog):
611611
app = jp_configurable_serverapp(no_browser_open_file=not should_exist)
612612
await app._post_start()
613613
assert os.path.exists(app.browser_open_file) == should_exist
@@ -616,6 +616,13 @@ async def test_browser_open_files(jp_configurable_serverapp, should_exist, caplo
616616
assert url_messages if should_exist else not url_messages
617617

618618

619+
@pytest.mark.parametrize("should_exist", [True, False])
620+
def test_no_browser_open_file_cli(jp_configurable_serverapp, should_exist):
621+
argv = ["--ServerApp.no_browser_open_file=" + str(should_exist)]
622+
app = jp_configurable_serverapp(argv=argv)
623+
assert app.no_browser_open_file == should_exist
624+
625+
619626
def test_deprecated_notebook_dir_priority(jp_configurable_serverapp, tmp_path):
620627
notebook_dir = tmp_path / "notebook"
621628
notebook_dir.mkdir()

0 commit comments

Comments
 (0)