Skip to content

Commit 5c96c6b

Browse files
committed
test(pane): Improve capture_pane tests w/ retry and visible lines assert
1 parent 4370a7e commit 5c96c6b

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

tests/test_pane.py

+26-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from libtmux.common import has_gte_version, has_lt_version, has_lte_version
99
from libtmux.constants import PaneDirection, ResizeAdjustmentDirection
1010
from libtmux.session import Session
11+
from libtmux.test import retry_until
1112

1213
logger = logging.getLogger(__name__)
1314

@@ -100,14 +101,31 @@ def test_capture_pane_start(session: Session) -> None:
100101
pane_contents = "\n".join(pane.capture_pane())
101102
assert pane_contents == '$ printf "%s"\n$'
102103
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)
111129

112130

113131
def test_capture_pane_end(session: Session) -> None:

0 commit comments

Comments
 (0)