You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
from gcode.ui.detect import CONHOST_HINT, detect_terminal, resolve_ui_mode
|
|
|
|
|
|
def test_windows_terminal_by_session() -> None:
|
|
info = detect_terminal(env={"WT_SESSION": "abc"}, parent_name="")
|
|
assert info.tui_ok
|
|
assert info.host == "windows-terminal"
|
|
|
|
|
|
def test_vscode_term_program() -> None:
|
|
info = detect_terminal(env={"TERM_PROGRAM": "vscode"}, parent_name="unknown")
|
|
assert info.tui_ok
|
|
|
|
|
|
def test_conhost_cmd() -> None:
|
|
info = detect_terminal(env={}, parent_name="cmd.exe")
|
|
assert not info.tui_ok
|
|
assert info.host == "conhost"
|
|
|
|
|
|
def test_auto_falls_back_to_repl() -> None:
|
|
info = detect_terminal(env={}, parent_name="cmd.exe")
|
|
mode, warning = resolve_ui_mode("auto", info)
|
|
assert mode == "repl"
|
|
assert "Windows Terminal" in warning
|
|
assert warning == CONHOST_HINT
|
|
|
|
|
|
def test_force_tui_on_conhost_refused() -> None:
|
|
info = detect_terminal(env={}, parent_name="cmd.exe")
|
|
mode, warning = resolve_ui_mode("tui", info)
|
|
assert mode == "refuse"
|
|
assert "repl" in warning.lower() or "Windows Terminal" in warning
|
|
|
|
|
|
def test_force_repl_always() -> None:
|
|
info = detect_terminal(env={"WT_SESSION": "1"}, parent_name="WindowsTerminal.exe")
|
|
mode, warning = resolve_ui_mode("repl", info)
|
|
assert mode == "repl"
|
|
assert warning == ""
|