|
9 | 9 | import io
|
10 | 10 | import re
|
11 | 11 | import tarfile
|
12 |
| -import warnings |
13 | 12 | from inspect import cleandoc
|
14 | 13 | from pathlib import Path
|
15 | 14 | from unittest.mock import Mock
|
|
24 | 23 | from setuptools.config import expand, pyprojecttoml, setupcfg
|
25 | 24 | from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter
|
26 | 25 | from setuptools.dist import Distribution
|
27 |
| -from setuptools.errors import RemovedConfigError |
| 26 | +from setuptools.errors import InvalidConfigError, RemovedConfigError |
28 | 27 | from setuptools.warnings import SetuptoolsDeprecationWarning
|
29 | 28 |
|
30 | 29 | from .downloads import retrieve_file, urls_from_file
|
@@ -331,26 +330,36 @@ def test_license_in_metadata(
|
331 | 330 | assert not_content_str not in content
|
332 | 331 |
|
333 | 332 |
|
334 |
| -def test_license_expression_with_bad_classifier(tmp_path): |
| 333 | +def test_license_classifier_with_license_expression(tmp_path): |
335 | 334 | text = PEP639_LICENSE_EXPRESSION.rsplit("\n", 2)[0]
|
336 | 335 | pyproject = _pep621_example_project(
|
337 | 336 | tmp_path,
|
338 | 337 | "README",
|
339 | 338 | f"{text}\n \"License :: OSI Approved :: MIT License\"\n]",
|
340 | 339 | )
|
341 |
| - msg = "License classifier are deprecated(?:.|\n)*'License :: OSI Approved :: MIT License'" |
342 |
| - with pytest.raises(SetuptoolsDeprecationWarning, match=msg): |
| 340 | + msg = "License classifiers have been superseded by license expressions" |
| 341 | + with pytest.raises(InvalidConfigError, match=msg) as exc: |
343 | 342 | pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
344 | 343 |
|
345 |
| - with warnings.catch_warnings(): |
346 |
| - warnings.simplefilter("ignore", SetuptoolsDeprecationWarning) |
| 344 | + assert "License :: OSI Approved :: MIT License" in str(exc.value) |
| 345 | + |
| 346 | + |
| 347 | +def test_license_classifier_without_license_expression(tmp_path): |
| 348 | + text = """\ |
| 349 | + [project] |
| 350 | + name = "spam" |
| 351 | + version = "2020.0.0" |
| 352 | + license = {text = "mit or apache-2.0"} |
| 353 | + classifiers = ["License :: OSI Approved :: MIT License"] |
| 354 | + """ |
| 355 | + pyproject = _pep621_example_project(tmp_path, "README", text) |
| 356 | + |
| 357 | + msg = "License classifiers are deprecated(?:.|\n)*MIT License" |
| 358 | + with pytest.warns(SetuptoolsDeprecationWarning, match=msg): |
347 | 359 | dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
348 |
| - # Check license classifier is still included |
349 |
| - assert dist.metadata.get_classifiers() == [ |
350 |
| - "Development Status :: 5 - Production/Stable", |
351 |
| - "Programming Language :: Python", |
352 |
| - "License :: OSI Approved :: MIT License", |
353 |
| - ] |
| 360 | + |
| 361 | + # Check license classifier is still included |
| 362 | + assert dist.metadata.get_classifiers() == ["License :: OSI Approved :: MIT License"] |
354 | 363 |
|
355 | 364 |
|
356 | 365 | class TestLicenseFiles:
|
|
0 commit comments