summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setuptools/tests/config/test_pyprojecttoml.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/setuptools/tests/config/test_pyprojecttoml.py b/setuptools/tests/config/test_pyprojecttoml.py
index 1b5b90e2..c0ee2378 100644
--- a/setuptools/tests/config/test_pyprojecttoml.py
+++ b/setuptools/tests/config/test_pyprojecttoml.py
@@ -9,8 +9,11 @@ from path import Path as _Path
from setuptools.config.pyprojecttoml import (
read_configuration,
expand_configuration,
+ apply_configuration,
validate,
+ _InvalidFile,
)
+from setuptools.dist import Distribution
from setuptools.errors import OptionError
@@ -348,3 +351,41 @@ def test_include_package_data_in_setuppy(tmp_path):
assert dist.get_name() == "myproj"
assert dist.get_version() == "42"
assert dist.include_package_data is False
+
+
+class TestSkipBadConfig:
+ @pytest.mark.parametrize(
+ "setup_attrs",
+ [
+ {"name": "myproj"},
+ {"install_requires": ["does-not-exist"]},
+ ],
+ )
+ @pytest.mark.parametrize(
+ "pyproject_content",
+ [
+ "[project]\nrequires-python = '>=3.7'\n",
+ "[project]\nversion = '42'\nrequires-python = '>=3.7'\n",
+ pytest.param(
+ "[project]\nname='othername'\nrequires-python = '>=3.7'\n",
+ marks=pytest.mark.xfail(reason="abravalheri/validate-pyproject#28")
+ ),
+ ],
+ )
+ def test_popular_config(self, tmp_path, pyproject_content, setup_attrs):
+ # See pypa/setuptools#3199 and pypa/cibuildwheel#1064
+ pyproject = tmp_path / "pyproject.toml"
+ pyproject.write_text(pyproject_content)
+ dist = Distribution(attrs=setup_attrs)
+
+ prev_name = dist.get_name()
+ prev_deps = dist.install_requires
+ print(f"{dist=}, {prev_name=}, {prev_deps=}")
+
+ with pytest.warns(_InvalidFile, match=r"DO NOT include.*\[project\].* table"):
+ dist = apply_configuration(dist, pyproject)
+
+ assert dist.get_name() != "othername"
+ assert dist.get_name() == prev_name
+ assert dist.python_requires is None
+ assert set(dist.install_requires) == set(prev_deps)