1
1
import os
2
2
import sys
3
3
import json
4
+ import shutil
4
5
import pytest
5
6
import asyncio
6
7
from binascii import hexlify
@@ -71,7 +72,6 @@ def mkdir(tmp_path, *parts):
71
72
}
72
73
argv = pytest .fixture (lambda : [])
73
74
74
-
75
75
@pytest .fixture
76
76
def environ (
77
77
monkeypatch ,
@@ -88,6 +88,18 @@ def environ(
88
88
):
89
89
monkeypatch .setenv ("HOME" , str (home_dir ))
90
90
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
+
91
103
# monkeypatch.setenv("JUPYTER_NO_CONFIG", "1")
92
104
monkeypatch .setenv ("JUPYTER_CONFIG_DIR" , str (config_dir ))
93
105
monkeypatch .setenv ("JUPYTER_DATA_DIR" , str (data_dir ))
@@ -101,6 +113,10 @@ def environ(
101
113
)
102
114
monkeypatch .setattr (jupyter_core .paths , "ENV_CONFIG_PATH" , [str (env_config_path )])
103
115
116
+ # copy nbconvert templates to new tmp data_dir.
117
+ if nbconvert_path :
118
+ shutil .copytree (nbconvert_path , str (nbconvert_target ))
119
+
104
120
105
121
@pytest .fixture
106
122
def extension_environ (env_config_path , monkeypatch ):
0 commit comments