Skip to content

Commit 5ea3820

Browse files
committed
Allow tests to influence env
1 parent 5a13c61 commit 5ea3820

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

jupyter_server/tests/launchserver.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ def request(cls, verb, path, **kwargs):
9090
**kwargs)
9191
return response
9292

93+
@classmethod
94+
def get_patch_env(cls):
95+
return {
96+
'HOME': cls.home_dir,
97+
'PYTHONPATH': os.pathsep.join(sys.path),
98+
'JUPYTER_NO_CONFIG': '1', # needed in the future
99+
'JUPYTER_CONFIG_DIR' : cls.config_dir,
100+
'JUPYTER_DATA_DIR' : cls.data_dir,
101+
'JUPYTER_RUNTIME_DIR': cls.runtime_dir,
102+
}
103+
93104
@classmethod
94105
def get_argv(cls):
95106
return []
@@ -111,14 +122,7 @@ def tmp(*parts):
111122
config_dir = cls.config_dir = tmp('config')
112123
runtime_dir = cls.runtime_dir = tmp('runtime')
113124
cls.root_dir = tmp('root_dir')
114-
cls.env_patch = patch.dict('os.environ', {
115-
'HOME': cls.home_dir,
116-
'PYTHONPATH': os.pathsep.join(sys.path),
117-
'JUPYTER_NO_CONFIG': '1', # needed in the future
118-
'JUPYTER_CONFIG_DIR' : config_dir,
119-
'JUPYTER_DATA_DIR' : data_dir,
120-
'JUPYTER_RUNTIME_DIR': runtime_dir,
121-
})
125+
cls.env_patch = patch.dict('os.environ', cls.get_patch_env())
122126
cls.env_patch.start()
123127
cls.path_patch = patch.multiple(
124128
jupyter_core.paths,

0 commit comments

Comments
 (0)