Skip to content

Commit

Permalink
👹 Feed the hobgoblins (delint).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 19, 2023
1 parent 784fb8f commit b60b007
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,39 +338,47 @@ def test_add_from_site_is_ignored(self):
assert not pth.dirty

def test_many_pth_distributions_merge_together(self, tmpdir):
"""Make sure that if the pth file is modified under the hood then PthDistribution
will refresh its content before saving, and merging contents when necessary.
"""
If the pth file is modified under the hood, then PthDistribution
will refresh its content before saving, merging contents when
necessary.
"""
# putting the pth file in a dedicated sub-folder,
pth_subdir = tmpdir.join("pth_subdir")
pth_subdir.mkdir()
pth_path = str(pth_subdir.join("file1.pth"))
pth1 = PthDistributions(pth_path)
pth2 = PthDistributions(pth_path)
assert pth1.paths == pth2.paths == [], \
"unless there would be some default added at some point"
assert (
pth1.paths == pth2.paths == []
), "unless there would be some default added at some point"
# and so putting the src_subdir in folder distinct than the pth one,
# so to keep it absolute by PthDistributions
new_src_path = tmpdir.join("src_subdir")
new_src_path.mkdir() # must exist to be accounted
new_src_path_str = str(new_src_path)
pth1.paths.append(new_src_path_str)
pth1.save()
assert pth1.paths, \
"first, the new_src_path added must still be present/valid in pth1 after save"
assert (
pth1.paths
), "the new_src_path added must still be present/valid in pth1 after save"
# now,
assert new_src_path_str not in pth2.paths, \
"right before we save the entry should still not be present"
assert (
new_src_path_str not in pth2.paths
), "right before we save the entry should still not be present"
pth2.save()
assert new_src_path_str in pth2.paths, \
"the new_src_path entry should have been added by pth2 with its save() call now"
assert pth2.paths[-1] == new_src_path, \
"and it should match exactly on the last entry actually " \
assert (
new_src_path_str in pth2.paths
), "the new_src_path entry should have been added by pth2 with its save() call"
assert pth2.paths[-1] == new_src_path, (
"and it should match exactly on the last entry actually "
"given we append to it in save()"
)
# finally,
assert PthDistributions(pth_path).paths == pth2.paths, \
"and we should have the exact same list at the end " \
assert PthDistributions(pth_path).paths == pth2.paths, (
"and we should have the exact same list at the end "
"with a fresh PthDistributions instance"
)


@pytest.fixture
Expand Down

0 comments on commit b60b007

Please sign in to comment.