mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-06-27 16:10:24 +08:00
[tests] test yaml files using jupyter_nbextensions_configurator
to avoid typos which may prevent nbextensions getting installed
This commit is contained in:
@@ -26,7 +26,7 @@ requirements:
|
||||
- jupyter_core
|
||||
- jupyter_highlight_selected_word >=0.0.10
|
||||
- jupyter_latex_envs >=1.3.8
|
||||
- jupyter_nbextensions_configurator >=0.2.6
|
||||
- jupyter_nbextensions_configurator >=0.2.8
|
||||
- nbconvert >=4.2
|
||||
- notebook >=4.0
|
||||
- pyyaml
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ipython
|
||||
jupyter_highlight_selected_word>=0.0.5
|
||||
jupyter_latex_envs>=1.3.4
|
||||
jupyter_nbextensions_configurator
|
||||
jupyter_nbextensions_configurator>=0.2.8
|
||||
readthedocs-sphinx-ext
|
||||
recommonmark>=0.4.0
|
||||
sphinx>=1.3.6,<1.6
|
||||
|
||||
@@ -66,7 +66,7 @@ if you encounter any problems, and create a new issue if needed!
|
||||
'jupyter_core',
|
||||
'jupyter_highlight_selected_word >=0.0.10',
|
||||
'jupyter_latex_envs >=1.3.8',
|
||||
'jupyter_nbextensions_configurator >=0.2.6',
|
||||
'jupyter_nbextensions_configurator >=0.2.8',
|
||||
'nbconvert >=4.2',
|
||||
'notebook >=4.0',
|
||||
'pyyaml',
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import (
|
||||
absolute_import, division, print_function, unicode_literals,
|
||||
)
|
||||
|
||||
import io
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
@@ -14,15 +15,18 @@ from unittest import TestCase
|
||||
|
||||
import jupyter_core.paths
|
||||
import nose.tools as nt
|
||||
import yaml
|
||||
from jupyter_contrib_core.notebook_compat import nbextensions
|
||||
from jupyter_contrib_core.testing_utils import (
|
||||
get_logger, patch_traitlets_app_logs,
|
||||
)
|
||||
from jupyter_contrib_core.testing_utils.jupyter_env import patch_jupyter_dirs
|
||||
from jupyter_nbextensions_configurator import _process_nbextension_spec
|
||||
from nose.plugins.skip import SkipTest
|
||||
from traitlets.config import Config
|
||||
from traitlets.tests.utils import check_help_all_output, check_help_output
|
||||
|
||||
import jupyter_contrib_nbextensions
|
||||
from jupyter_contrib_nbextensions.application import main as main_app
|
||||
from jupyter_contrib_nbextensions.application import (
|
||||
BaseContribNbextensionsApp, BaseContribNbextensionsInstallApp,
|
||||
@@ -31,6 +35,12 @@ from jupyter_contrib_nbextensions.application import (
|
||||
)
|
||||
from jupyter_contrib_nbextensions.install import toggle_install
|
||||
|
||||
# attempt to use LibYaml if available
|
||||
try:
|
||||
from yaml import CSafeLoader as SafeLoader
|
||||
except ImportError:
|
||||
from yaml import SafeLoader
|
||||
|
||||
app_classes = (
|
||||
BaseContribNbextensionsApp, BaseContribNbextensionsInstallApp,
|
||||
ContribNbextensionsApp,
|
||||
@@ -312,3 +322,24 @@ class AppTest(TestCase):
|
||||
self.check_app_install(
|
||||
argv=argv + ['--only-config'], dirs=dirs,
|
||||
dirs_install={'conf': dirs['conf']})
|
||||
|
||||
def test_16_yaml_files(self):
|
||||
"""Check that the configurator accepts all nbextension yaml files."""
|
||||
errmsg = ''
|
||||
root_nbext_dir = os.path.join(os.path.dirname(
|
||||
jupyter_contrib_nbextensions.__file__), 'nbextensions')
|
||||
for direct, dirs, files in os.walk(root_nbext_dir, followlinks=True):
|
||||
for fname in files:
|
||||
if os.path.splitext(fname)[1] not in ('.yml', '.yaml'):
|
||||
continue
|
||||
yaml_path = os.path.join(direct, fname)
|
||||
with io.open(yaml_path, 'r', encoding='utf-8') as stream:
|
||||
try:
|
||||
spec = yaml.load(stream, Loader=SafeLoader)
|
||||
except yaml.YAMLError:
|
||||
errmsg += '\nFailed to load yaml: {}'.format(yaml_path)
|
||||
continue
|
||||
spec = _process_nbextension_spec(spec)
|
||||
if not isinstance(spec, dict):
|
||||
errmsg += '\n{}: {}'.format(spec, os.path.reyaml_path)
|
||||
nt.assert_false(len(errmsg), 'Error loading yaml file(s):' + errmsg)
|
||||
|
||||
Reference in New Issue
Block a user