Skip to content

Commit c97ab5d

Browse files
committed
Clean up path deduplication test
1 parent 09fa118 commit c97ab5d

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

jupyter_core/tests/test_paths.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ def test_jupyter_path():
198198
def test_jupyter_path_user_site():
199199
with no_config_env, patch.object(site, 'ENABLE_USER_SITE', True):
200200
path = jupyter_path()
201-
sitedir = os.path.join(site.getuserbase(), 'share', 'jupyter')
202-
assert path.pop(0) == jupyter_data_dir()
203-
if jupyter_data_dir() != sitedir:
204-
assert path.pop(0) == sitedir
205-
assert path.pop(0) == paths.ENV_JUPYTER_PATH[0]
201+
202+
# deduplicated expected values
203+
values = list(dict.fromkeys([
204+
jupyter_data_dir(),
205+
os.path.join(site.getuserbase(), 'share', 'jupyter'),
206+
paths.ENV_JUPYTER_PATH[0]
207+
]))
208+
for p,v in zip(path, values):
209+
assert p == v
206210

207211
def test_jupyter_path_no_user_site():
208212
with no_config_env, patch.object(site, 'ENABLE_USER_SITE', False):
@@ -241,11 +245,15 @@ def test_jupyter_path_subdir():
241245
def test_jupyter_config_path():
242246
with patch.object(site, 'ENABLE_USER_SITE', True):
243247
path = jupyter_config_path()
244-
sitedir = os.path.join(site.USER_BASE, 'etc', 'jupyter')
245-
assert path.pop(0) == jupyter_config_dir()
246-
if jupyter_config_dir() != sitedir:
247-
assert path.pop(0) == sitedir
248-
assert path.pop(0) == paths.ENV_CONFIG_PATH[0]
248+
249+
# deduplicated expected values
250+
values = list(dict.fromkeys([
251+
jupyter_config_dir(),
252+
os.path.join(site.getuserbase(), 'etc', 'jupyter'),
253+
paths.ENV_CONFIG_PATH[0]
254+
]))
255+
for p,v in zip(path, values):
256+
assert p == v
249257

250258
def test_jupyter_config_path_no_user_site():
251259
with patch.object(site, 'ENABLE_USER_SITE', False):
@@ -255,11 +263,17 @@ def test_jupyter_config_path_no_user_site():
255263

256264

257265
def test_jupyter_config_path_prefer_env():
258-
with prefer_env:
266+
with prefer_env, patch.object(site, 'ENABLE_USER_SITE', True):
259267
path = jupyter_config_path()
260-
assert path[0] == paths.ENV_CONFIG_PATH[0]
261-
assert path[1] == jupyter_config_dir()
262-
assert path[2] == os.path.join(site.USER_BASE, 'etc', 'jupyter')
268+
269+
# deduplicated expected values
270+
values = list(dict.fromkeys([
271+
paths.ENV_CONFIG_PATH[0],
272+
jupyter_config_dir(),
273+
os.path.join(site.getuserbase(), 'etc', 'jupyter')
274+
]))
275+
for p,v in zip(path, values):
276+
assert p == v
263277

264278
def test_jupyter_config_path_env():
265279
path_env = os.pathsep.join([

0 commit comments

Comments
 (0)