Skip to content

Commit f92cbda

Browse files
committed
tests(util) Patch for isatty
1 parent b423e74 commit f92cbda

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_util.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import sys
56
import typing as t
67

78
import pytest
@@ -35,8 +36,18 @@ def test_run_before_script_raise_BeforeLoadScriptError_if_retcode() -> None:
3536
run_before_script(script_file)
3637

3738

38-
def test_return_stdout_if_ok(capsys: pytest.CaptureFixture[str]) -> None:
39+
def test_return_stdout_if_ok(
40+
capsys: pytest.CaptureFixture[str],
41+
monkeypatch: pytest.MonkeyPatch,
42+
) -> None:
3943
"""run_before_script() returns stdout if script succeeds."""
44+
45+
def mock_isatty() -> bool:
46+
return True # or False for non-TTY tests
47+
48+
monkeypatch.setattr(sys.stdout, "isatty", mock_isatty)
49+
monkeypatch.setattr(sys.stderr, "isatty", mock_isatty)
50+
4051
script_file = FIXTURE_PATH / "script_complete.sh"
4152

4253
run_before_script(script_file)

0 commit comments

Comments
 (0)