From a97282753bdd5be9019c978dc35a2a98728d43df Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Tue, 12 Oct 2021 14:28:18 -0700 Subject: [PATCH] Clean up path deduplication test --- jupyter_core/tests/test_paths.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/jupyter_core/tests/test_paths.py b/jupyter_core/tests/test_paths.py index 07c8225a..534e82cd 100644 --- a/jupyter_core/tests/test_paths.py +++ b/jupyter_core/tests/test_paths.py @@ -198,11 +198,15 @@ def test_jupyter_path(): def test_jupyter_path_user_site(): with no_config_env, patch.object(site, 'ENABLE_USER_SITE', True): path = jupyter_path() - sitedir = os.path.join(site.getuserbase(), 'share', 'jupyter') - assert path.pop(0) == jupyter_data_dir() - if jupyter_data_dir() != sitedir: - assert path.pop(0) == sitedir - assert path.pop(0) == paths.ENV_JUPYTER_PATH[0] + + # deduplicated expected values + values = list(dict.fromkeys([ + jupyter_data_dir(), + os.path.join(site.getuserbase(), 'share', 'jupyter'), + paths.ENV_JUPYTER_PATH[0] + ])) + for p,v in zip(path, values): + assert p == v def test_jupyter_path_no_user_site(): with no_config_env, patch.object(site, 'ENABLE_USER_SITE', False): @@ -241,11 +245,14 @@ def test_jupyter_path_subdir(): def test_jupyter_config_path(): with patch.object(site, 'ENABLE_USER_SITE', True): path = jupyter_config_path() - sitedir = os.path.join(site.USER_BASE, 'etc', 'jupyter') - assert path.pop(0) == jupyter_config_dir() - if jupyter_config_dir() != sitedir: - assert path.pop(0) == sitedir - assert path.pop(0) == paths.ENV_CONFIG_PATH[0] + # deduplicated expected values + values = list(dict.fromkeys([ + jupyter_config_dir(), + os.path.join(site.USER_BASE, 'etc', 'jupyter'), + paths.ENV_CONFIG_PATH[0] + ])) + for p,v in zip(path, values): + assert p == v def test_jupyter_config_path_no_user_site(): with patch.object(site, 'ENABLE_USER_SITE', False):