From ca0ee009f81a460b483c7e451e58dfdcd7787045 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 11 Sep 2019 16:39:57 +0100 Subject: Add test capturing failure. Ref #1787. --- setuptools/tests/test_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index bc97664d..42187138 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -819,6 +819,18 @@ class TestOptions: ] assert sorted(dist.data_files) == sorted(expected) + def test_python_requires_invalid(self, tmpdir): + fake_env( + tmpdir, + DALS(""" + [options] + python_requires=invalid + """), + ) + with pytest.raises(DistutilsOptionError): + with get_dist(tmpdir) as dist: + dist.parse_config_files() + saved_dist_init = _Distribution.__init__ -- cgit v1.2.1 From b31777cd50c7cb59b4ef6c22bd014f0229ef32fa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 11 Sep 2019 16:52:58 +0100 Subject: Add more tests for valid behavior. Expand exception, any should do. --- setuptools/tests/test_config.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index 42187138..1b94a586 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -819,6 +819,28 @@ class TestOptions: ] assert sorted(dist.data_files) == sorted(expected) + def test_python_requires_simple(self, tmpdir): + fake_env( + tmpdir, + DALS(""" + [options] + python_requires=>=2.7 + """), + ) + with get_dist(tmpdir) as dist: + dist.parse_config_files() + + def test_python_requires_compound(self, tmpdir): + fake_env( + tmpdir, + DALS(""" + [options] + python_requires=>=2.7,!=3.0.* + """), + ) + with get_dist(tmpdir) as dist: + dist.parse_config_files() + def test_python_requires_invalid(self, tmpdir): fake_env( tmpdir, @@ -827,7 +849,7 @@ class TestOptions: python_requires=invalid """), ) - with pytest.raises(DistutilsOptionError): + with pytest.raises(Exception): with get_dist(tmpdir) as dist: dist.parse_config_files() -- cgit v1.2.1 From c3df086ed3570e7065e6935a52d95c8cdef2b071 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 11 Sep 2019 16:54:07 +0100 Subject: Ensure that python_requires is checked during option processing. Fixes #1787. --- setuptools/config.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools') diff --git a/setuptools/config.py b/setuptools/config.py index b6626043..2d50e25e 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -12,6 +12,7 @@ from importlib import import_module from distutils.errors import DistutilsOptionError, DistutilsFileError from setuptools.extern.packaging.version import LegacyVersion, parse +from setuptools.extern.packaging.specifiers import SpecifierSet from setuptools.extern.six import string_types, PY3 @@ -554,6 +555,7 @@ class ConfigOptionsHandler(ConfigHandler): 'packages': self._parse_packages, 'entry_points': self._parse_file, 'py_modules': parse_list, + 'python_requires': SpecifierSet, } def _parse_packages(self, value): -- cgit v1.2.1