def test_read_setup_py_simple(tmp_path): with open(tmp_path / "setup.py", "w") as f: f.write(dedent(""" from setuptools import setup setup( name = "hello", other = 23, example = ["item", "other"], python_requires = "1.23", ) """)) assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) == "1.23" assert get_requires_python_str(tmp_path) == "1.23"
def test_read_setup_py_empty(tmp_path): with open(tmp_path / "setup.py", "w") as f: f.write(dedent(""" from setuptools import setup REQUIRES = "3.21" setuptools.setup( name = "hello", other = 23, example = ["item", "other"], ) """)) assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) is None assert get_requires_python_str(tmp_path) is None
def test_read_setup_py_full(tmp_path): with open(tmp_path / "setup.py", "w", encoding="utf8") as f: f.write( dedent(""" import setuptools setuptools.randomfunc() setuptools.setup( name = "hello", description = "≥“”ü", other = 23, example = ["item", "other"], python_requires = "1.24", ) """)) assert (setup_py_python_requires( tmp_path.joinpath("setup.py").read_text(encoding="utf8")) == "1.24") assert get_requires_python_str(tmp_path) == "1.24"