|
4 | 4 |
|
5 | 5 | import pytest
|
6 | 6 |
|
7 |
| -from cleo.io.outputs.output import Verbosity |
8 |
| - |
9 | 7 | from poetry.utils._compat import WINDOWS
|
| 8 | +from poetry.utils.env import MockEnv |
10 | 9 |
|
11 | 10 |
|
12 | 11 | if TYPE_CHECKING:
|
| 12 | + from cleo.testers.application_tester import ApplicationTester |
13 | 13 | from cleo.testers.command_tester import CommandTester
|
14 | 14 | from pytest_mock import MockerFixture
|
15 | 15 |
|
@@ -45,7 +45,7 @@ def test_env_activate_prints_correct_script(
|
45 | 45 | mocker.patch("shellingham.detect_shell", return_value=(shell, None))
|
46 | 46 | mocker.patch("poetry.utils.env.EnvManager.get", return_value=tmp_venv)
|
47 | 47 |
|
48 |
| - tester.execute(verbosity=Verbosity.VERBOSE) |
| 48 | + tester.execute() |
49 | 49 |
|
50 | 50 | line = tester.io.fetch_output().rstrip("\n")
|
51 | 51 | assert line == f"{command} {tmp_venv.bin_dir}/activate{ext}"
|
@@ -76,3 +76,20 @@ def test_env_activate_prints_correct_script_on_windows(
|
76 | 76 |
|
77 | 77 | line = tester.io.fetch_output().rstrip("\n")
|
78 | 78 | 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