Skip to content

Commit

Permalink
Fix setup of nbconvert templates
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-bates committed Sep 18, 2020
1 parent 097676b commit c357778
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion jupyter_server/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import json
import shutil
import pytest
import asyncio
from binascii import hexlify
Expand Down Expand Up @@ -71,7 +72,6 @@ def mkdir(tmp_path, *parts):
}
argv = pytest.fixture(lambda: [])


@pytest.fixture
def environ(
monkeypatch,
Expand All @@ -88,6 +88,18 @@ def environ(
):
monkeypatch.setenv("HOME", str(home_dir))
monkeypatch.setenv("PYTHONPATH", os.pathsep.join(sys.path))

# Get path to nbconvert template directory *before*
# monkeypatching the paths env variable.
possible_paths = jupyter_core.paths.jupyter_path('nbconvert', 'templates')
nbconvert_path = None
for path in possible_paths:
if os.path.exists(path):
nbconvert_path = path
break

nbconvert_target = data_dir / 'nbconvert' / 'templates'

# monkeypatch.setenv("JUPYTER_NO_CONFIG", "1")
monkeypatch.setenv("JUPYTER_CONFIG_DIR", str(config_dir))
monkeypatch.setenv("JUPYTER_DATA_DIR", str(data_dir))
Expand All @@ -101,6 +113,10 @@ def environ(
)
monkeypatch.setattr(jupyter_core.paths, "ENV_CONFIG_PATH", [str(env_config_path)])

# copy nbconvert templates to new tmp data_dir.
if nbconvert_path:
shutil.copytree(nbconvert_path, str(nbconvert_target))


@pytest.fixture
def extension_environ(env_config_path, monkeypatch):
Expand Down

0 comments on commit c357778

Please sign in to comment.