Skip to content

Commit a846afe

Browse files
committed
adding tests for the scenario where the environment is not a virtual environment
1 parent 7ce6c82 commit a846afe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_shell_command.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,19 @@ def test__is_venv_activated(
8686
os.environ["POETRY_ACTIVE"] = poetry_active
8787

8888
assert tester.command._is_venv_activated() is expected
89+
90+
91+
def test_is_not_venv(tester: CommandTester, mocker: MockerFixture) -> None:
92+
shell_activate = mocker.patch("poetry_plugin_shell.shell.Shell.activate")
93+
tester.command.env.is_venv = lambda: False
94+
95+
tester.execute()
96+
assert isinstance(tester.command, ShellCommand)
97+
expected_output = (
98+
f"The Python environment at {tester.command.env.path} "
99+
"cannot be activated as it is not a virtural environment.\n"
100+
)
101+
102+
shell_activate.assert_not_called()
103+
assert tester.io.fetch_error() == expected_output
104+
assert tester.status_code == 1

0 commit comments

Comments
 (0)