From 566f2948d2fc452109da4e0cf20ac4e113e07809 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 12 Sep 2023 13:31:55 +0100 Subject: [PATCH] Test command line parsing of '--version' interoperates with pyproject.toml --- .../tests/config/test_apply_pyprojecttoml.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index c0c6b13392..294947a00a 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -423,6 +423,25 @@ def test_example_file_not_in_wheel(self, setuptools_wheel): assert not any(name.endswith(EXAMPLES_FILE) for name in zipfile.namelist()) +class TestInteropCommandLineParsing: + def test_version(self, tmp_path, monkeypatch, capsys): + # See pypa/setuptools#4047 + # This test can be removed once the CLI interface of setup.py is removed + monkeypatch.chdir(tmp_path) + toml_config = """ + [project] + name = "test" + version = "42.0" + """ + pyproject = Path(tmp_path, "pyproject.toml") + pyproject.write_text(cleandoc(toml_config), encoding="utf-8") + opts = {"script_args": ["--version"]} + dist = pyprojecttoml.apply_configuration(Distribution(opts), pyproject) + dist.parse_command_line() # <-- there should be no exception here. + captured = capsys.readouterr() + assert "42.0" in captured.out + + # --- Auxiliary Functions ---