Skip to content

Commit

Permalink
Allow ServerApp.no_browser_open_file option to be set via config / cl…
Browse files Browse the repository at this point in the history
…i args
  • Loading branch information
devoidfury committed Feb 14, 2025
1 parent c67a46b commit 379f760
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,11 @@ def _default_info_file(self) -> str:
return os.path.join(self.runtime_dir, info_file)

no_browser_open_file = Bool(
False, help="If True, do not write redirect HTML file disk, or show in messages."
False,
config=True,
help=_i18n(
"If True, do not write redirect HTML file disk, or show in startup output messages."
),
)

browser_open_file = Unicode()
Expand Down
9 changes: 8 additions & 1 deletion tests/test_serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def test_running_server_info(jp_serverapp):


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


@pytest.mark.parametrize("should_exist", [True, False])
def test_no_browser_open_file_cli(jp_configurable_serverapp, should_exist):
argv = ["--ServerApp.no_browser_open_file=" + str(should_exist)]
app = jp_configurable_serverapp(argv=argv)
assert app.no_browser_open_file == should_exist


def test_deprecated_notebook_dir_priority(jp_configurable_serverapp, tmp_path):
notebook_dir = tmp_path / "notebook"
notebook_dir.mkdir()
Expand Down

0 comments on commit 379f760

Please sign in to comment.