|
8 | 8 | from libtmux.common import has_gte_version, has_lt_version, has_lte_version
|
9 | 9 | from libtmux.constants import PaneDirection, ResizeAdjustmentDirection
|
10 | 10 | from libtmux.session import Session
|
| 11 | +from libtmux.test import retry_until |
11 | 12 |
|
12 | 13 | logger = logging.getLogger(__name__)
|
13 | 14 |
|
@@ -100,14 +101,31 @@ def test_capture_pane_start(session: Session) -> None:
|
100 | 101 | pane_contents = "\n".join(pane.capture_pane())
|
101 | 102 | assert pane_contents == '$ printf "%s"\n$'
|
102 | 103 | pane.send_keys("clear -x", literal=True, suppress_history=False)
|
103 |
| - pane_contents = "\n".join(pane.capture_pane()) |
104 |
| - assert pane_contents == "$" |
105 |
| - pane_contents_start = pane.capture_pane(start=-2) |
106 |
| - assert pane_contents_start[0] == '$ printf "%s"' |
107 |
| - assert pane_contents_start[1] == "$ clear -x" |
108 |
| - assert pane_contents_start[-1] == "$" |
109 |
| - pane_contents_start = pane.capture_pane(start="-") |
110 |
| - assert pane_contents == "$" |
| 104 | + |
| 105 | + def wait_until_pane_cleared() -> bool: |
| 106 | + pane_contents = "\n".join(pane.capture_pane()) |
| 107 | + return "clear -x" not in pane_contents |
| 108 | + |
| 109 | + retry_until(wait_until_pane_cleared, 1, raises=True) |
| 110 | + |
| 111 | + def pane_contents_shell_prompt() -> bool: |
| 112 | + pane_contents = "\n".join(pane.capture_pane()) |
| 113 | + return pane_contents == "$" |
| 114 | + |
| 115 | + retry_until(pane_contents_shell_prompt, 1, raises=True) |
| 116 | + |
| 117 | + pane_contents_history_start = pane.capture_pane(start=-2) |
| 118 | + assert pane_contents_history_start[0] == '$ printf "%s"' |
| 119 | + assert pane_contents_history_start[1] == "$ clear -x" |
| 120 | + assert pane_contents_history_start[-1] == "$" |
| 121 | + |
| 122 | + pane.send_keys("") |
| 123 | + |
| 124 | + def pane_contents_capture_visible_only_shows_prompt() -> bool: |
| 125 | + pane_contents = "\n".join(pane.capture_pane(start=1)) |
| 126 | + return pane_contents == "$" |
| 127 | + |
| 128 | + assert retry_until(pane_contents_capture_visible_only_shows_prompt, 1, raises=True) |
111 | 129 |
|
112 | 130 |
|
113 | 131 | def test_capture_pane_end(session: Session) -> None:
|
|
0 commit comments