|
48 | 48 |
|
49 | 49 | jupyter_config_env = '/jupyter-cfg'
|
50 | 50 | config_env = patch.dict('os.environ', {'JUPYTER_CONFIG_DIR': jupyter_config_env})
|
| 51 | +prefer_env = patch.dict('os.environ', {'JUPYTER_PREFER_ENV_PATH': 'True'}) |
| 52 | + |
| 53 | +resetenv = patch.dict(os.environ) |
| 54 | + |
| 55 | +def setup_module(): |
| 56 | + resetenv.start() |
| 57 | + os.environ.pop('JUPYTER_PREFER_ENV_PATH', None) |
| 58 | + |
| 59 | +def teardown_module(): |
| 60 | + resetenv.stop() |
| 61 | + |
51 | 62 |
|
52 | 63 |
|
53 | 64 | def realpath(path):
|
54 | 65 | return os.path.abspath(os.path.realpath(os.path.expanduser(path)))
|
55 | 66 |
|
56 | 67 | home_jupyter = realpath('~/.jupyter')
|
57 | 68 |
|
58 |
| - |
59 | 69 | def test_envset():
|
60 | 70 | true_values = ['', 'True', 'on', 'yes', 'Y', '1', 'anything']
|
61 | 71 | false_values = ['n', 'No', 'N', 'fAlSE', '0', '0.0', 'Off']
|
@@ -199,7 +209,7 @@ def test_jupyter_path_no_user_site():
|
199 | 209 | assert path[1] == paths.ENV_JUPYTER_PATH[0]
|
200 | 210 |
|
201 | 211 | def test_jupyter_path_prefer_env():
|
202 |
| - with patch.dict('os.environ', {'JUPYTER_PREFER_ENV_PATH': 'true'}): |
| 212 | + with prefer_env: |
203 | 213 | path = jupyter_path()
|
204 | 214 | assert path[0] == paths.ENV_JUPYTER_PATH[0]
|
205 | 215 | assert path[1] == jupyter_data_dir()
|
@@ -241,7 +251,7 @@ def test_jupyter_config_path_no_user_site():
|
241 | 251 |
|
242 | 252 |
|
243 | 253 | def test_jupyter_config_path_prefer_env():
|
244 |
| - with patch.dict('os.environ', {'JUPYTER_PREFER_ENV_PATH': 'true'}): |
| 254 | + with prefer_env: |
245 | 255 | path = jupyter_config_path()
|
246 | 256 | assert path[0] == paths.ENV_CONFIG_PATH[0]
|
247 | 257 | assert path[1] == jupyter_config_dir()
|
|
0 commit comments