v2.16.0 (#798)
Co-authored-by: Hdandria <henri.dandria@mistral.ai> Co-authored-by: Liam Lyons <65613603+lyons-liam@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: allansimon-mistral <allan.simon@ext.mistral.ai> Co-authored-by: angelapopopo <angele.lenglemetz@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
cafb6d4147
commit
c2cb612ac1
67 changed files with 2704 additions and 197 deletions
74
tests/cli/test_terminal_detect.py
Normal file
74
tests/cli/test_terminal_detect.py
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from vibe.cli.terminal_detect import Terminal, detect_terminal
|
||||
|
||||
|
||||
def _detect_with(env: dict[str, str]) -> Terminal:
|
||||
with patch.dict(os.environ, env, clear=True):
|
||||
return detect_terminal()
|
||||
|
||||
|
||||
def test_detects_vscode() -> None:
|
||||
assert _detect_with({"TERM_PROGRAM": "vscode"}) is Terminal.VSCODE
|
||||
|
||||
|
||||
def test_detects_vscode_insiders() -> None:
|
||||
assert (
|
||||
_detect_with({"TERM_PROGRAM": "vscode", "TERM_PROGRAM_VERSION": "1.2-insider"})
|
||||
is Terminal.VSCODE_INSIDERS
|
||||
)
|
||||
|
||||
|
||||
def test_detects_cursor_from_vscode_environment() -> None:
|
||||
assert (
|
||||
_detect_with({
|
||||
"TERM_PROGRAM": "vscode",
|
||||
"VSCODE_IPC_HOOK_CLI": "/Applications/Cursor.app/hook",
|
||||
})
|
||||
is Terminal.CURSOR
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("term_program", "terminal"),
|
||||
[
|
||||
("iterm.app", Terminal.ITERM2),
|
||||
("wezterm", Terminal.WEZTERM),
|
||||
("ghostty", Terminal.GHOSTTY),
|
||||
("alacritty", Terminal.ALACRITTY),
|
||||
("kitty", Terminal.KITTY),
|
||||
("hyper", Terminal.HYPER),
|
||||
],
|
||||
)
|
||||
def test_detects_term_program_mapping(term_program: str, terminal: Terminal) -> None:
|
||||
assert _detect_with({"TERM_PROGRAM": term_program}) is terminal
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("env_var", "terminal"),
|
||||
[
|
||||
("WEZTERM_PANE", Terminal.WEZTERM),
|
||||
("GHOSTTY_RESOURCES_DIR", Terminal.GHOSTTY),
|
||||
("KITTY_WINDOW_ID", Terminal.KITTY),
|
||||
("ALACRITTY_SOCKET", Terminal.ALACRITTY),
|
||||
("ALACRITTY_LOG", Terminal.ALACRITTY),
|
||||
("WT_SESSION", Terminal.WINDOWS_TERMINAL),
|
||||
],
|
||||
)
|
||||
def test_detects_environment_marker_fallback(env_var: str, terminal: Terminal) -> None:
|
||||
assert _detect_with({env_var: "1"}) is terminal
|
||||
|
||||
|
||||
def test_detects_jetbrains_environment_fallback() -> None:
|
||||
assert (
|
||||
_detect_with({"TERMINAL_EMULATOR": "JetBrains-JediTerm"}) is Terminal.JETBRAINS
|
||||
)
|
||||
|
||||
|
||||
def test_returns_unknown_without_markers() -> None:
|
||||
assert _detect_with({}) is Terminal.UNKNOWN
|
||||
Loading…
Add table
Add a link
Reference in a new issue