diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-26 13:54:56 +0000 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-26 13:54:56 +0000 |
commit | 1c47ae18c8c8c58a2e2b09bfc01028d747acfd66 (patch) | |
tree | 54bbaccf7cebf104e65071dce2e00e79bd4fe71a /setuptools/tests/config/test_pyprojecttoml.py | |
parent | cc910e2235268963a5f05433f29dacc7804676c5 (diff) | |
download | python-setuptools-git-1c47ae18c8c8c58a2e2b09bfc01028d747acfd66.tar.gz |
Test popular invalid pyproject patterns
Diffstat (limited to 'setuptools/tests/config/test_pyprojecttoml.py')
-rw-r--r-- | setuptools/tests/config/test_pyprojecttoml.py | 41 |
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) |