Skip to content

Commit

Permalink
Clear the test environment before each function run
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Jan 7, 2023
1 parent 6b4df54 commit 2add943
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions jupyter_core/tests/test_paths.py
Expand Up @@ -68,18 +68,15 @@
prefer_env = patch.dict("os.environ", {"JUPYTER_PREFER_ENV_PATH": "True"})
prefer_user = patch.dict("os.environ", {"JUPYTER_PREFER_ENV_PATH": "False"})

resetenv = patch.dict(os.environ)


def setup_module():
resetenv.start()
def setup_function():
no_config_env.start()
# For these tests, default to preferring the user-level over environment-level paths
# Tests can override this preference using the prefer_env decorator/context manager
os.environ["JUPYTER_PREFER_ENV_PATH"] = "no"


def teardown_module():
resetenv.stop()
def teardown_function():
no_config_env.stop()


def realpath(path):
Expand Down Expand Up @@ -272,14 +269,14 @@ def test_runtime_dir_linux():

def test_jupyter_path():
system_path = ["system", "path"]
with no_config_env, patch.object(paths, "SYSTEM_JUPYTER_PATH", system_path):
with patch.object(paths, "SYSTEM_JUPYTER_PATH", system_path):
path = 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):
with patch.object(site, "ENABLE_USER_SITE", True):
path = jupyter_path()

# deduplicated expected values
Expand All @@ -297,7 +294,7 @@ def test_jupyter_path_user_site():


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

0 comments on commit 2add943

Please sign in to comment.