Skip to content

Allow ServerApp.no_browser_open_file option to be set via config #1501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading