Skip to content

Commit

Permalink
Add tests for the user site path.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Oct 7, 2021
1 parent c571c98 commit b7bd178
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion jupyter_core/tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ def test_jupyter_path():
assert path[0] == jupyter_data_dir()
assert path[-2:] == system_path

def test_jupyter_path_user_site():
with no_config_env, patch.object(site, 'ENABLE_USER_SITE', True):
path = jupyter_path()
assert path[0] == jupyter_data_dir()
assert path[1] == os.path.join(site.getuserbase(), 'share', 'jupyter')
assert path[2] == paths.ENV_JUPYTER_PATH[0]

def test_jupyter_path_no_user_site():
with no_config_env, patch.object(site, 'ENABLE_USER_SITE', False):
path = jupyter_path()
assert path[0] == jupyter_data_dir()
assert path[1] == paths.ENV_JUPYTER_PATH[0]

def test_jupyter_path_prefer_env():
with patch.dict('os.environ', {'JUPYTER_PREFER_ENV_PATH': 'true'}):
path = jupyter_path()
Expand Down Expand Up @@ -214,11 +227,19 @@ def test_jupyter_path_subdir():
assert p.endswith(pjoin('', 'sub1', 'sub2'))

def test_jupyter_config_path():
path = jupyter_config_path()
with patch.object(site, 'ENABLE_USER_SITE', True):
path = jupyter_config_path()
assert path[0] == jupyter_config_dir()
assert path[1] == os.path.join(site.USER_BASE, 'etc', 'jupyter')
assert path[2] == paths.ENV_CONFIG_PATH[0]

def test_jupyter_config_path_no_user_site():
with patch.object(site, 'ENABLE_USER_SITE', False):
path = jupyter_config_path()
assert path[0] == jupyter_config_dir()
assert path[1] == paths.ENV_CONFIG_PATH[0]


def test_jupyter_config_path_prefer_env():
with patch.dict('os.environ', {'JUPYTER_PREFER_ENV_PATH': 'true'}):
path = jupyter_config_path()
Expand Down

0 comments on commit b7bd178

Please sign in to comment.