Skip to content

Commit 4818104

Browse files
committed
Add tests for deprecated license paths
1 parent 4929334 commit 4818104

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

setuptools/tests/test_bdist_wheel.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,48 @@ def test_dist_info_provided(dummy_dist, monkeypatch, tmp_path):
661661
assert expected - files_found == set()
662662
# Make sure there is no accidental egg-info bleeding into the wheel.
663663
assert not [path for path in files_found if 'egg-info' in str(path)]
664+
665+
666+
def test_allow_grace_period_parent_directory_license(monkeypatch, tmp_path):
667+
# Motivation: https://github.com/pypa/setuptools/issues/4892
668+
# TODO: Remove this test after deprecation period is over
669+
files = {
670+
"LICENSE.txt": "parent license", # <---- the license files are outside
671+
"NOTICE.txt": "parent notice",
672+
"python": {
673+
"pyproject.toml": cleandoc(
674+
"""
675+
[project]
676+
name = "test-proj"
677+
dynamic = ["version"] # <---- testing dynamic will not break
678+
[tool.setuptools.dynamic]
679+
version.file = "VERSION"
680+
"""
681+
),
682+
"setup.cfg": cleandoc(
683+
"""
684+
[metadata]
685+
license_files =
686+
../LICENSE.txt
687+
../NOTICE.txt
688+
"""
689+
),
690+
"VERSION": "42",
691+
},
692+
}
693+
jaraco.path.build(files, prefix=str(tmp_path))
694+
monkeypatch.chdir(tmp_path / "python")
695+
msg = "Pattern '../.*.txt' cannot contain '..'"
696+
with pytest.warns(SetuptoolsDeprecationWarning, match=msg):
697+
bdist_wheel_cmd().run()
698+
with ZipFile("dist/test_proj-42-py3-none-any.whl") as wf:
699+
files_found = set(wf.namelist())
700+
expected_files = {
701+
"test_proj-42.dist-info/licenses/LICENSE.txt",
702+
"test_proj-42.dist-info/licenses/NOTICE.txt",
703+
}
704+
assert expected_files <= files_found
705+
706+
metadata = wf.read("test_proj-42.dist-info/METADATA").decode("utf8")
707+
assert "License-File: LICENSE.txt" in metadata
708+
assert "License-File: NOTICE.txt" in metadata

0 commit comments

Comments
 (0)