Skip to content

Commit 23b0a84

Browse files
authored
Merge pull request #309 from kevin-bates/fix-nbconvert-tests
Fix setup of nbconvert templates
2 parents a7bf2e8 + c357778 commit 23b0a84

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

jupyter_server/pytest_plugin.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import json
4+
import shutil
45
import pytest
56
import asyncio
67
from binascii import hexlify
@@ -71,7 +72,6 @@ def mkdir(tmp_path, *parts):
7172
}
7273
argv = pytest.fixture(lambda: [])
7374

74-
7575
@pytest.fixture
7676
def environ(
7777
monkeypatch,
@@ -88,6 +88,18 @@ def environ(
8888
):
8989
monkeypatch.setenv("HOME", str(home_dir))
9090
monkeypatch.setenv("PYTHONPATH", os.pathsep.join(sys.path))
91+
92+
# Get path to nbconvert template directory *before*
93+
# monkeypatching the paths env variable.
94+
possible_paths = jupyter_core.paths.jupyter_path('nbconvert', 'templates')
95+
nbconvert_path = None
96+
for path in possible_paths:
97+
if os.path.exists(path):
98+
nbconvert_path = path
99+
break
100+
101+
nbconvert_target = data_dir / 'nbconvert' / 'templates'
102+
91103
# monkeypatch.setenv("JUPYTER_NO_CONFIG", "1")
92104
monkeypatch.setenv("JUPYTER_CONFIG_DIR", str(config_dir))
93105
monkeypatch.setenv("JUPYTER_DATA_DIR", str(data_dir))
@@ -101,6 +113,10 @@ def environ(
101113
)
102114
monkeypatch.setattr(jupyter_core.paths, "ENV_CONFIG_PATH", [str(env_config_path)])
103115

116+
# copy nbconvert templates to new tmp data_dir.
117+
if nbconvert_path:
118+
shutil.copytree(nbconvert_path, str(nbconvert_target))
119+
104120

105121
@pytest.fixture
106122
def extension_environ(env_config_path, monkeypatch):

0 commit comments

Comments
 (0)