Skip to content

Fix tests with nbconvert 6 #5086

Closed
@takluyver

Description

@takluyver

With nbconvert 6, notebook's tests fail, as in the traceback below. #5085 pinned nbconvert <6 so it's not holding up other work, but unpinning in a PR should reproduce it (unless changes in nbconvert fix it).

I believe that this is caused by notebook's tests monkeypatching various paths to make the tests independent of the user's real environment:

cls.path_patch = patch.multiple(
jupyter_core.paths,
SYSTEM_JUPYTER_PATH=[tmp('share', 'jupyter')],
ENV_JUPYTER_PATH=[tmp('env', 'share', 'jupyter')],
SYSTEM_CONFIG_PATH=[tmp('etc', 'jupyter')],
ENV_CONFIG_PATH=[tmp('env', 'etc', 'jupyter')],
)

Nbconvert 6 uses jupyter path() to find its templates, so these patches mean they can no longer be found. We either need to special case them, or relax the isolation a bit.


NotebookApp: ERROR: nbconvert failed: No template sub-directory with name 'classic' found in the following paths:
	/tmp/tmp6wqtbpho/data
	/tmp/tmp6wqtbpho/env/share/jupyter
	/tmp/tmp6wqtbpho/share/jupyter
Traceback (most recent call last):
  File "/home/travis/build/jupyter/notebook/notebook/nbconvert/handlers.py", line 132, in get
    resources=resource_dict
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/html.py", line 99, in from_notebook_node
    self.register_filter('highlight_code', highlight_code)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 418, in register_filter
    return self._register_filter(self.environment, name, jinja_filter)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 154, in environment
    self._environment_cached = self._create_environment()
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 436, in _create_environment
    paths = self.get_template_paths()
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 465, in get_template_paths
    template_names = self.get_template_names()
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 512, in get_template_names
    raise ValueError('No template sub-directory with name %r found in the following paths:\n\t%s' % (template_name, paths))
ValueError: No template sub-directory with name 'classic' found in the following paths:
	/tmp/tmp6wqtbpho/data
	/tmp/tmp6wqtbpho/env/share/jupyter
	/tmp/tmp6wqtbpho/share/jupyter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions