浏览代码

use jupyterlab_server pytest plugin

Eric Charles 5 年之前
父节点
当前提交
d71d74a614
共有 3 个文件被更改,包括 19 次插入7 次删除
  1. 7 0
      conftest.py
  2. 11 6
      jupyterlab/labapp.py
  3. 1 1
      setup.py

+ 7 - 0
conftest.py

@@ -5,6 +5,13 @@
 
 import pytest
 
+
+pytest_plugins = [
+    'pytest_jupyter_server',
+    'pytest_jupyterlab_server',
+]
+
+
 def pytest_addoption(parser):
     """
     Adds flags for py.test.

+ 11 - 6
jupyterlab/labapp.py

@@ -494,10 +494,14 @@ class LabApp(ExtensionApp, ExtensionAppJinjaMixin):
     # Local path to templates directory.
     template_paths = []
 
+    # The config.
+    c = None
+
     def initialize_templates(self):
-        c = load_config(self)
-        self.static_paths = [c.static_dir]
-        self.template_paths = [c.templates_dir]
+        if self.c == None:
+            self.c = load_config(self)
+            self.static_paths = [self.c.static_dir]
+            self.template_paths = [self.c.templates_dir]
         if len(self.template_paths) > 0:
             self.settings.update({
                 "{}_template_paths".format(self.extension_name): self.template_paths
@@ -534,9 +538,10 @@ class LabApp(ExtensionApp, ExtensionAppJinjaMixin):
 
         The extension API is experimental, and may change in future releases.
         """
-        c = load_config(self)
-        self.static_paths = [c.static_dir]
-        self.template_paths = [c.templates_dir]
+        if self.c == None:
+            self.c = load_config(self)
+            self.static_paths = [self.c.static_dir]
+            self.template_paths = [self.c.templates_dir]
         if not self.serverapp.jpserver_extensions.get('jupyterlab', False):
             msg = 'JupyterLab server extension not enabled, manually loading...'
             self.log.warning(msg)

+ 1 - 1
setup.py

@@ -172,7 +172,7 @@ setup_args['entry_points'] = {
         'jupyter-labextension = jupyterlab.labextensions:main',
         'jupyter-labhub = jupyterlab.labhubapp:main',
         'jlpm = jupyterlab.jlpmapp:main',
-    ]
+    ],
 }