1111from libtmux .common import has_gte_version , has_lt_version , has_lte_version
1212from libtmux .constants import PaneDirection , ResizeAdjustmentDirection
1313from libtmux .test .retry import retry_until
14+ from libtmux ._internal .waiter import expect
1415
1516if t .TYPE_CHECKING :
1617 from libtmux .session import Session
@@ -107,17 +108,13 @@ def test_capture_pane_start(session: Session) -> None:
107108 assert pane_contents == '$ printf "%s"\n $'
108109 pane .send_keys ("clear -x" , literal = True , suppress_history = False )
109110
110- def wait_until_pane_cleared () -> bool :
111- pane_contents = "\n " .join (pane .capture_pane ())
112- return "clear -x" not in pane_contents
113-
114- retry_until (wait_until_pane_cleared , 1 , raises = True )
115-
116- def pane_contents_shell_prompt () -> bool :
117- pane_contents = "\n " .join (pane .capture_pane ())
118- return pane_contents == "$"
111+ # Using the waiter functionality to wait for the pane to be cleared
112+ expect (pane ).wait_for_predicate (
113+ lambda lines : "clear -x" not in "\n " .join (lines )
114+ )
119115
120- retry_until (pane_contents_shell_prompt , 1 , raises = True )
116+ # Using the waiter functionality to wait for shell prompt
117+ expect (pane ).wait_for_exact_text ("$" )
121118
122119 pane_contents_history_start = pane .capture_pane (start = - 2 )
123120 assert pane_contents_history_start [0 ] == '$ printf "%s"'
@@ -126,11 +123,9 @@ def pane_contents_shell_prompt() -> bool:
126123
127124 pane .send_keys ("" )
128125
129- def pane_contents_capture_visible_only_shows_prompt () -> bool :
130- pane_contents = "\n " .join (pane .capture_pane (start = 1 ))
131- return pane_contents == "$"
132-
133- assert retry_until (pane_contents_capture_visible_only_shows_prompt , 1 , raises = True )
126+ # Using the waiter functionality to verify content
127+ result = expect (pane ).with_line_range (1 , None ).wait_for_exact_text ("$" )
128+ assert result .success
134129
135130
136131def test_capture_pane_end (session : Session ) -> None :
0 commit comments