|
5 | 5 |
|
6 | 6 | from setuptools.config.pyprojecttoml import apply_configuration
|
7 | 7 | from setuptools.dist import Distribution
|
| 8 | +from setuptools.warnings import SetuptoolsWarning |
8 | 9 |
|
9 | 10 |
|
10 | 11 | def test_dynamic_dependencies(tmp_path):
|
@@ -77,23 +78,32 @@ def test_mixed_dynamic_optional_dependencies(tmp_path):
|
77 | 78 |
|
78 | 79 | [tool.setuptools.dynamic.optional-dependencies.images]
|
79 | 80 | file = ["requirements-images.txt"]
|
80 |
| -
|
81 |
| - [build-system] |
82 |
| - requires = ["setuptools", "wheel"] |
83 |
| - build-backend = "setuptools.build_meta" |
84 | 81 | """
|
85 | 82 | ),
|
86 | 83 | }
|
87 | 84 |
|
88 | 85 | path.build(files, prefix=tmp_path)
|
89 |
| - |
90 |
| - # Test that the mix-and-match doesn't currently validate. |
91 | 86 | pyproject = tmp_path / "pyproject.toml"
|
92 | 87 | with pytest.raises(ValueError, match="project.optional-dependencies"):
|
93 | 88 | apply_configuration(Distribution(), pyproject)
|
94 | 89 |
|
95 |
| - # Explicitly disable the validation and try again, to see that the mix-and-match |
96 |
| - # result would be correct. |
97 |
| - dist = Distribution() |
98 |
| - dist = apply_configuration(dist, pyproject, ignore_option_errors=True) |
99 |
| - assert dist.extras_require == {"docs": ["sphinx"], "images": ["pillow~=42.0"]} |
| 90 | + |
| 91 | +def test_mixed_extras_require_optional_dependencies(tmp_path): |
| 92 | + files = { |
| 93 | + "pyproject.toml": cleandoc( |
| 94 | + """ |
| 95 | + [project] |
| 96 | + name = "myproj" |
| 97 | + version = "1.0" |
| 98 | + optional-dependencies.docs = ["sphinx"] |
| 99 | + """ |
| 100 | + ), |
| 101 | + } |
| 102 | + |
| 103 | + path.build(files, prefix=tmp_path) |
| 104 | + pyproject = tmp_path / "pyproject.toml" |
| 105 | + |
| 106 | + with pytest.warns(SetuptoolsWarning, match=".extras_require. overwritten"): |
| 107 | + dist = Distribution({"extras_require": {"hello": ["world"]}}) |
| 108 | + dist = apply_configuration(dist, pyproject) |
| 109 | + assert dist.extras_require == {"docs": ["sphinx"]} |
0 commit comments