Skip to content

Commit d3eb200

Browse files
committed
test verbosity in a separate test, test all verbose modes
1 parent 1f140d4 commit d3eb200

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tests/console/commands/env/test_activate.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import pytest
66

7-
from cleo.io.outputs.output import Verbosity
8-
97
from poetry.utils._compat import WINDOWS
8+
from poetry.utils.env import MockEnv
109

1110

1211
if TYPE_CHECKING:
12+
from cleo.testers.application_tester import ApplicationTester
1313
from cleo.testers.command_tester import CommandTester
1414
from pytest_mock import MockerFixture
1515

@@ -45,7 +45,7 @@ def test_env_activate_prints_correct_script(
4545
mocker.patch("shellingham.detect_shell", return_value=(shell, None))
4646
mocker.patch("poetry.utils.env.EnvManager.get", return_value=tmp_venv)
4747

48-
tester.execute(verbosity=Verbosity.VERBOSE)
48+
tester.execute()
4949

5050
line = tester.io.fetch_output().rstrip("\n")
5151
assert line == f"{command} {tmp_venv.bin_dir}/activate{ext}"
@@ -76,3 +76,20 @@ def test_env_activate_prints_correct_script_on_windows(
7676

7777
line = tester.io.fetch_output().rstrip("\n")
7878
assert line == f'{prefix}"{tmp_venv.bin_dir / ext!s}"'
79+
80+
81+
@pytest.mark.parametrize("verbosity", ["", "-v", "-vv", "-vvv"])
82+
def test_no_additional_output_in_verbose_mode(
83+
tmp_venv: VirtualEnv,
84+
mocker: MockerFixture,
85+
app_tester: ApplicationTester,
86+
verbosity: str,
87+
) -> None:
88+
mocker.patch("shellingham.detect_shell", return_value=("pwsh", None))
89+
mocker.patch("poetry.utils.env.EnvManager.get", return_value=MockEnv(is_venv=True))
90+
91+
# use an AppTester instead of a CommandTester to catch additional output
92+
app_tester.execute(f"env activate {verbosity}")
93+
94+
lines = app_tester.io.fetch_output().splitlines()
95+
assert len(lines) == 1

0 commit comments

Comments
 (0)