Skip to content

Commit df2cca6

Browse files
committed
Small adjustments and fixes to make tests work
1 parent c31ebdc commit df2cca6

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

setuptools/dist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def _find_pattern(pattern: str, enforce_match: bool = True) -> list[str]:
515515
"Pattern {pattern!r} contains invalid characters.",
516516
pattern=pattern,
517517
see_url=f"https://packaging.python.org/en/latest/{pypa_guides}",
518-
due_date=(2025, 2, 20), # Introduced in 2024-02-20
518+
due_date=(2026, 2, 20), # Introduced in 2025-02-20
519519
)
520520

521521
found = glob(pattern, recursive=True)
@@ -525,7 +525,7 @@ def _find_pattern(pattern: str, enforce_match: bool = True) -> list[str]:
525525
"Cannot find any files for the given pattern.",
526526
"Pattern {pattern!r} did not match any files.",
527527
pattern=pattern,
528-
due_date=(2025, 2, 20), # Introduced in 2024-02-20
528+
due_date=(2026, 2, 20), # Introduced in 2025-02-20
529529
# PEP 639 requires us to error, but as a transition period
530530
# we will only issue a warning to give people time to prepare.
531531
# After the transition, this should raise an InvalidConfigError.

setuptools/tests/config/test_apply_pyprojecttoml.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter
2525
from setuptools.dist import Distribution
2626
from setuptools.errors import InvalidConfigError, RemovedConfigError
27-
from setuptools.warnings import SetuptoolsDeprecationWarning
27+
from setuptools.warnings import InformationOnly, SetuptoolsDeprecationWarning
2828

2929
from .downloads import retrieve_file, urls_from_file
3030

@@ -36,11 +36,22 @@ def makedist(path, **attrs):
3636
return Distribution({"src_root": path, **attrs})
3737

3838

39+
def _mock_expand_patterns(patterns, *_, **__):
40+
"""
41+
Allow comparing the given patterns for 2 dist objects.
42+
We need to strip special chars to avoid errors when validating.
43+
"""
44+
return [re.sub("[^a-z0-9]+", "", p, flags=re.I) or "empty" for p in patterns]
45+
46+
3947
@pytest.mark.parametrize("url", urls_from_file(HERE / EXAMPLES_FILE))
4048
@pytest.mark.filterwarnings("ignore")
4149
@pytest.mark.uses_network
4250
def test_apply_pyproject_equivalent_to_setupcfg(url, monkeypatch, tmp_path):
4351
monkeypatch.setattr(expand, "read_attr", Mock(return_value="0.0.1"))
52+
monkeypatch.setattr(
53+
Distribution, "_expand_patterns", Mock(side_effect=_mock_expand_patterns)
54+
)
4455
setupcfg_example = retrieve_file(url)
4556
pyproject_example = Path(tmp_path, "pyproject.toml")
4657
setupcfg_text = setupcfg_example.read_text(encoding="utf-8")
@@ -432,7 +443,10 @@ def test_both_license_and_license_files_defined_pep639(self, tmp_path):
432443
(tmp_path / "_FILE.txt").touch()
433444
(tmp_path / "_FILE.rst").touch()
434445

435-
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
446+
msg = "Normalizing.*LicenseRef"
447+
with pytest.warns(InformationOnly, match=msg):
448+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
449+
436450
assert set(dist.metadata.license_files) == {"_FILE.rst", "_FILE.txt"}
437451
assert dist.metadata.license is None
438452
assert dist.metadata.license_expression == "LicenseRef-Proprietary"
@@ -465,8 +479,12 @@ def test_missing_patterns(self, tmp_path):
465479
pyproject = self.base_pyproject_license_pep639(tmp_path)
466480
assert list(tmp_path.glob("_FILE*")) == [] # sanity check
467481

468-
msg = "Cannot find any files for the given pattern.*"
469-
with pytest.warns(SetuptoolsDeprecationWarning, match=msg):
482+
msg1 = "Cannot find any files for the given pattern.*"
483+
msg2 = "Normalizing 'licenseref-Proprietary' to 'LicenseRef-Proprietary'"
484+
with (
485+
pytest.warns(SetuptoolsDeprecationWarning, match=msg1),
486+
pytest.warns(InformationOnly, match=msg2),
487+
):
470488
pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
471489

472490
def test_deprecated_file_expands_to_text(self, tmp_path):

0 commit comments

Comments
 (0)