Skip to content

Commit

Permalink
Fix windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus committed Oct 27, 2024
1 parent b0d10c4 commit 27ab23a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/console/commands/env/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
),
)
@pytest.mark.skipif(WINDOWS, reason="Only Unix shells")
def test_env_activate_prints_correct_script_windows(
def test_env_activate_prints_correct_script(
tmp_venv: VirtualEnv,
mocker: MockerFixture,
tester: CommandTester,
Expand All @@ -50,26 +50,27 @@ def test_env_activate_prints_correct_script_windows(


@pytest.mark.parametrize(
"shell, command, ext",
"shell, command, ext, prefix",
(
("cmd", ".", "activate.bat"),
("pwsh", ".", "Activate.ps1"),
("powershell", ".", "Activate.ps1"),
("cmd", ".", "activate.bat", ""),
("pwsh", ".", "Activate.ps1", "& "),
("powershell", ".", "Activate.ps1", "& "),
),
)
@pytest.mark.skipif(not WINDOWS, reason="Only Windows shells")
def test_env_activate_prints_correct_script(
def test_env_activate_prints_correct_script_on_windows(
tmp_venv: VirtualEnv,
mocker: MockerFixture,
tester: CommandTester,
shell: str,
command: str,
ext: str,
prefix: str,
) -> None:
mocker.patch("shellingham.detect_shell", return_value=(shell, None))
mocker.patch("poetry.utils.env.EnvManager.get", return_value=tmp_venv)

tester.execute()

line = tester.io.fetch_output().split("\n")[0]
assert line == str(tmp_venv.bin_dir / ext)
assert line == f'{prefix}"{tmp_venv.bin_dir / ext!s}"'

0 comments on commit 27ab23a

Please sign in to comment.