diff --git a/jupyter_server/extension/application.py b/jupyter_server/extension/application.py index dfe12f02bd..a68fc57c88 100644 --- a/jupyter_server/extension/application.py +++ b/jupyter_server/extension/application.py @@ -283,6 +283,7 @@ def _prepare_config(self): """Builds a Config object from the extension's traits and passes the object to the webapp's settings as `_config`. """ + self.update_config(self.config) traits = self.class_own_traits().keys() self.extension_config = Config({t: getattr(self, t) for t in traits}) self.settings['{}_config'.format(self.extension_name)] = self.extension_config @@ -365,7 +366,7 @@ def initialize_server(cls, argv=[], load_other_extensions=True, **kwargs): serverapp.initialize(argv=argv, load_extensions=load_other_extensions) return serverapp - def initialize(self, serverapp, argv=[]): + def initialize(self, serverapp, argv=None): """Initialize the extension app. This method: @@ -378,6 +379,12 @@ def initialize(self, serverapp, argv=[]): # Initialize ServerApp. self.serverapp = serverapp + # If argv is given, parse and update config. + if argv: + self.parse_command_line(argv) + # Load config from file. + self.load_config_file() + # Initialize config, settings, templates, and handlers. self._prepare_config() self._prepare_templates() diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 2e7ce1b304..37b22c5c66 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1493,7 +1493,7 @@ def init_server_extension_config(self): app_obj = metadata[0].get('app', None) if app_obj: if not issubclass(app_obj, JupyterApp): - raise TypeError(abb_obj.__name__ + "must be a subclass of JupyterApp") + raise TypeError(abb_obj.__name__ + " must be a subclass of JupyterApp.") # Initialize extension app app = app_obj(parent=self) # Update the app's config, setting diff --git a/tests/extension/conftest.py b/tests/extension/conftest.py index 28e419ad45..11d212acd4 100644 --- a/tests/extension/conftest.py +++ b/tests/extension/conftest.py @@ -42,13 +42,13 @@ def _jupyter_server_extension_paths(): }] @pytest.fixture -def make_mock_extension_app(template_dir): +def make_mock_extension_app(template_dir, config_dir): def _make_mock_extension_app(**kwargs): kwargs.setdefault('template_paths', [str(template_dir)]) - return MockExtensionApp(**kwargs) + return MockExtensionApp(config_dir=str(config_dir), **kwargs) # TODO Should the index template creation be only be done only once? - index = template_dir.joinpath("index.html") + index = template_dir.joinpath("index.html") index.write_text("""