From 3ecc6446effdb60d50799297f3962068dfe29c9c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 25 Nov 2024 01:05:56 +0100 Subject: [PATCH] Additional test case --- .../tests/config/test_apply_pyprojecttoml.py | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index 42e68a14be..b44c479998 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -314,9 +314,6 @@ def test_license_in_metadata( class TestLicenseFiles: - # TODO: After PEP 639 is accepted, we have to move the license-files - # to the `project` table instead of `tool.setuptools` - def base_pyproject(self, tmp_path, additional_text): pyproject = _pep621_example_project(tmp_path, "README") text = pyproject.read_text(encoding="utf-8") @@ -329,6 +326,24 @@ def base_pyproject(self, tmp_path, additional_text): pyproject.write_text(text, encoding="utf-8") return pyproject + def base_pyproject_license_pep639(self, tmp_path): + pyproject = _pep621_example_project(tmp_path, "README") + text = pyproject.read_text(encoding="utf-8") + + # Sanity-check + assert 'license = {file = "LICENSE.txt"}' in text + assert 'license-files' not in text + assert "[tool.setuptools]" not in text + + text = re.sub( + r"(license = {file = \"LICENSE.txt\"})\n", + ("license = \"licenseref-Proprietary\"\nlicense-files = [\"_FILE*\"]\n"), + text, + count=1, + ) + pyproject.write_text(text, encoding="utf-8") + return pyproject + def test_both_license_and_license_files_defined(self, tmp_path): setuptools_config = '[tool.setuptools]\nlicense-files = ["_FILE*"]' pyproject = self.base_pyproject(tmp_path, setuptools_config) @@ -345,6 +360,18 @@ def test_both_license_and_license_files_defined(self, tmp_path): assert set(dist.metadata.license_files) == {"_FILE.rst", "_FILE.txt"} assert dist.metadata.license == "LicenseRef-Proprietary\n" + def test_both_license_and_license_files_defined_pep639(self, tmp_path): + # Set license and license-files + pyproject = self.base_pyproject_license_pep639(tmp_path) + + (tmp_path / "_FILE.txt").touch() + (tmp_path / "_FILE.rst").touch() + + dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject) + assert set(dist.metadata.license_files) == {"_FILE.rst", "_FILE.txt"} + assert dist.metadata.license is None + assert dist.metadata.license_expression == "LicenseRef-Proprietary" + def test_default_patterns(self, tmp_path): setuptools_config = '[tool.setuptools]\nzip-safe = false' # ^ used just to trigger section validation