File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 ExtensionHandlerJinjaMixin ,
1515 ExtensionHandlerMixin ,
1616)
17- from jupyter_server .serverapp import flags
17+ from jupyter_server .serverapp import ServerApp , flags
1818from jupyter_server .utils import url_escape , url_is_absolute
1919from jupyter_server .utils import url_path_join as ujoin
2020from jupyterlab .commands import (
@@ -355,6 +355,16 @@ def initialize_handlers(self) -> None:
355355 self .handlers .append (("/custom/custom.css" , CustomCssHandler ))
356356 super ().initialize_handlers ()
357357
358+ @classmethod
359+ def make_serverapp (cls , ** kwargs : t .Any ) -> ServerApp :
360+ """
361+ Add the notebook flags to the server that parses the command line,
362+ because jupyter_server merges only the extension aliases.
363+ """
364+ serverapp = super ().make_serverapp (** kwargs )
365+ serverapp .flags .update (cls .flags ) # type:ignore[arg-type]
366+ return serverapp
367+
358368 def initialize (self , argv : list [str ] | None = None ) -> None : # noqa: ARG002
359369 """Subclass because the ExtensionApp.initialize() method does not take arguments"""
360370 super ().initialize ()
Original file line number Diff line number Diff line change 11import os
22
33import pytest
4+ from jupyter_server .serverapp import ServerApp
45from jupyter_server .serverapp import flags as serverapp_flags
56from tornado .httpclient import HTTPClientError
67
@@ -27,6 +28,17 @@ def test_notebook_app_flags_are_isolated():
2728 assert notebook_flags .isdisjoint (serverapp_flags )
2829
2930
31+ def test_notebook_app_flags_reach_serverapp ():
32+ ServerApp .clear_instance ()
33+ try :
34+ serverapp = JupyterNotebookApp .make_serverapp ()
35+ serverapp .parse_command_line (["--expose-app-in-browser" , "--custom-css" ])
36+ assert serverapp .config .JupyterNotebookApp .expose_app_in_browser is True
37+ assert serverapp .config .JupyterNotebookApp .custom_css is True
38+ finally :
39+ ServerApp .clear_instance ()
40+
41+
3042async def test_notebook_handler (notebooks , jp_fetch ):
3143 for nbpath in notebooks :
3244 r = await jp_fetch ("/" , nbpath )
You can’t perform that action at this time.
0 commit comments