From a84da6d0e66c49da6af30a735fe2a1c9abe6987f Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Mon, 11 Nov 2024 08:47:00 -0300 Subject: [PATCH] build(deps): bump minimum craft-cli to 2.10.1 Version 2.10.1 fixes the issue where the app greeting is shown twice when running in managed mode, which happened because the Emitter was initialized in "verbose" and then the Dispatcher set it to verbose again when parsing the command line. Fixes #551 --- pyproject.toml | 2 +- tests/integration/test_application.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 62515806..8ee15518 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ description = "A framework for *craft applications." dynamic = ["version", "readme"] dependencies = [ "craft-archives>=2.0.0", - "craft-cli>=2.9.0", + "craft-cli>=2.10.1", "craft-grammar>=2.0.0", "craft-parts>=2.1.1", "craft-platforms>=0.3.1", diff --git a/tests/integration/test_application.py b/tests/integration/test_application.py index b722ce02..ad1676b1 100644 --- a/tests/integration/test_application.py +++ b/tests/integration/test_application.py @@ -462,3 +462,24 @@ def test_runtime_error_logging(monkeypatch, tmp_path, create_app, mocker): # Make sure it's identified as the correct error type parts_message = "Parts processing internal error: An unexpected error" assert parts_message in log_contents + + +def test_verbosity_greeting(monkeypatch, create_app, capsys): + """Test that 'verbose' runs only show the greeting once.""" + + # Set the verbosity *both* through the environment variable and the + # command line, to ensure that the greeting is only shown once even with + # multiple verbosity "settings". + monkeypatch.setenv("CRAFT_VERBOSITY_LEVEL", "verbose") + monkeypatch.setattr("sys.argv", ["testcraft", "i-dont-exist", "-v"]) + + app = create_app() + with pytest.raises(SystemExit): + app.run() + + _, err = capsys.readouterr() + lines = err.splitlines() + greetings = [line for line in lines if line.startswith("Starting testcraft")] + + # Exactly one greeting + assert len(greetings) == 1