|
24 | 24 | from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter
|
25 | 25 | from setuptools.dist import Distribution
|
26 | 26 | from setuptools.errors import RemovedConfigError
|
| 27 | +from setuptools.warnings import SetuptoolsDeprecationWarning |
27 | 28 |
|
28 | 29 | from .downloads import retrieve_file, urls_from_file
|
29 | 30 |
|
@@ -347,18 +348,47 @@ def test_pyproject_sets_attribute(self, tmp_path, monkeypatch):
|
347 | 348 |
|
348 | 349 |
|
349 | 350 | class TestDeprecatedFields:
|
350 |
| - def test_namespace_packages(self, tmp_path): |
| 351 | + @pytest.mark.parametrize( |
| 352 | + ("field", "value"), |
| 353 | + [ |
| 354 | + ("provides", "['setuptools']"), |
| 355 | + ("obsoletes", "['obsoletes']"), |
| 356 | + ], |
| 357 | + ) |
| 358 | + def test_still_valid(self, tmp_path, field, value): |
| 359 | + pyproject = tmp_path / "pyproject.toml" |
| 360 | + config = f""" |
| 361 | + [project] |
| 362 | + name = "myproj" |
| 363 | + version = "42" |
| 364 | + [tool.setuptools] |
| 365 | + {field} = {value} |
| 366 | + """ |
| 367 | + pyproject.write_text(cleandoc(config), encoding="utf-8") |
| 368 | + match = f"Deprecated usage of `tool.setuptools.{field}`" |
| 369 | + with pytest.warns(SetuptoolsDeprecationWarning, match=match): |
| 370 | + pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject) |
| 371 | + |
| 372 | + @pytest.mark.parametrize( |
| 373 | + ("field", "value"), |
| 374 | + [ |
| 375 | + ("namespace-packages", "['myproj.pkg']"), |
| 376 | + ("requires", "['setuptools']"), |
| 377 | + ], |
| 378 | + ) |
| 379 | + def test_removed(self, tmp_path, field, value): |
351 | 380 | pyproject = tmp_path / "pyproject.toml"
|
352 |
| - config = """ |
| 381 | + config = f""" |
353 | 382 | [project]
|
354 | 383 | name = "myproj"
|
355 | 384 | version = "42"
|
356 | 385 | [tool.setuptools]
|
357 |
| - namespace-packages = ["myproj.pkg"] |
| 386 | + {field} = {value} |
358 | 387 | """
|
359 | 388 | pyproject.write_text(cleandoc(config), encoding="utf-8")
|
360 |
| - with pytest.raises(RemovedConfigError, match="namespace-packages"): |
| 389 | + with pytest.raises((RemovedConfigError, ValueError)) as exc: |
361 | 390 | pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 391 | + assert f"tool.setuptools.{field}" in str(exc.value) |
362 | 392 |
|
363 | 393 |
|
364 | 394 | class TestPresetField:
|
@@ -498,7 +528,10 @@ def test_mark_static_fields(self, tmp_path, monkeypatch):
|
498 | 528 | """
|
499 | 529 | pyproject = Path(tmp_path, "pyproject.toml")
|
500 | 530 | pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
|
501 |
| - dist = pyprojecttoml.apply_configuration(Distribution({}), pyproject) |
| 531 | + |
| 532 | + with pytest.warns(SetuptoolsDeprecationWarning, match="Deprecated usage of"): |
| 533 | + dist = pyprojecttoml.apply_configuration(Distribution({}), pyproject) |
| 534 | + |
502 | 535 | assert is_static(dist.install_requires)
|
503 | 536 | assert is_static(dist.metadata.keywords)
|
504 | 537 | assert is_static(dist.metadata.classifiers)
|
|
0 commit comments