24
24
from setuptools .config ._apply_pyprojecttoml import _MissingDynamic , _some_attrgetter
25
25
from setuptools .dist import Distribution
26
26
from setuptools .errors import InvalidConfigError , RemovedConfigError
27
- from setuptools .warnings import SetuptoolsDeprecationWarning
27
+ from setuptools .warnings import InformationOnly , SetuptoolsDeprecationWarning
28
28
29
29
from .downloads import retrieve_file , urls_from_file
30
30
@@ -36,11 +36,22 @@ def makedist(path, **attrs):
36
36
return Distribution ({"src_root" : path , ** attrs })
37
37
38
38
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
+
39
47
@pytest .mark .parametrize ("url" , urls_from_file (HERE / EXAMPLES_FILE ))
40
48
@pytest .mark .filterwarnings ("ignore" )
41
49
@pytest .mark .uses_network
42
50
def test_apply_pyproject_equivalent_to_setupcfg (url , monkeypatch , tmp_path ):
43
51
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
+ )
44
55
setupcfg_example = retrieve_file (url )
45
56
pyproject_example = Path (tmp_path , "pyproject.toml" )
46
57
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):
432
443
(tmp_path / "_FILE.txt" ).touch ()
433
444
(tmp_path / "_FILE.rst" ).touch ()
434
445
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
+
436
450
assert set (dist .metadata .license_files ) == {"_FILE.rst" , "_FILE.txt" }
437
451
assert dist .metadata .license is None
438
452
assert dist .metadata .license_expression == "LicenseRef-Proprietary"
@@ -465,8 +479,12 @@ def test_missing_patterns(self, tmp_path):
465
479
pyproject = self .base_pyproject_license_pep639 (tmp_path )
466
480
assert list (tmp_path .glob ("_FILE*" )) == [] # sanity check
467
481
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
+ ):
470
488
pyprojecttoml .apply_configuration (makedist (tmp_path ), pyproject )
471
489
472
490
def test_deprecated_file_expands_to_text (self , tmp_path ):
0 commit comments