|
18 | 18 | from libtmux.server import Server
|
19 | 19 |
|
20 | 20 |
|
| 21 | +class TTYTestFixture(t.NamedTuple): |
| 22 | + """Test fixture for isatty behavior verification.""" |
| 23 | + |
| 24 | + test_id: str |
| 25 | + isatty_value: bool |
| 26 | + expected_output: str |
| 27 | + |
| 28 | + |
| 29 | +TTY_TEST_FIXTURES: list[TTYTestFixture] = [ |
| 30 | + TTYTestFixture( |
| 31 | + test_id="tty_enabled_shows_output", |
| 32 | + isatty_value=True, |
| 33 | + expected_output="Hello, World!", |
| 34 | + ), |
| 35 | + TTYTestFixture( |
| 36 | + test_id="tty_disabled_suppresses_output", |
| 37 | + isatty_value=False, |
| 38 | + expected_output="", |
| 39 | + ), |
| 40 | +] |
| 41 | + |
| 42 | + |
21 | 43 | def test_run_before_script_raise_BeforeLoadScriptNotExists_if_not_exists() -> None:
|
22 | 44 | """run_before_script() raises BeforeLoadScriptNotExists if script not found."""
|
23 | 45 | script_file = FIXTURE_PATH / "script_noexists.sh"
|
@@ -52,16 +74,15 @@ def temp_script(tmp_path: pathlib.Path) -> pathlib.Path:
|
52 | 74 |
|
53 | 75 |
|
54 | 76 | @pytest.mark.parametrize(
|
55 |
| - ["isatty_value", "expected_output"], |
56 |
| - [ |
57 |
| - (True, "Hello, World!"), # if stdout is a TTY, output should be passed through |
58 |
| - (False, ""), # if not a TTY, output is not written to sys.stdout |
59 |
| - ], |
| 77 | + list(TTYTestFixture._fields), |
| 78 | + TTY_TEST_FIXTURES, |
| 79 | + ids=[test.test_id for test in TTY_TEST_FIXTURES], |
60 | 80 | )
|
61 | 81 | def test_run_before_script_isatty(
|
62 | 82 | temp_script: pathlib.Path,
|
63 | 83 | monkeypatch: pytest.MonkeyPatch,
|
64 | 84 | capsys: pytest.CaptureFixture[str],
|
| 85 | + test_id: str, |
65 | 86 | isatty_value: bool,
|
66 | 87 | expected_output: str,
|
67 | 88 | ) -> None:
|
|
0 commit comments