88
99import pytest
1010
11+ from libtmux ._internal .waiter import expect
1112from libtmux .common import has_gte_version , has_lt_version , has_lte_version
1213from libtmux .constants import PaneDirection , ResizeAdjustmentDirection
13- from libtmux .test .retry import retry_until
1414
1515if t .TYPE_CHECKING :
1616 from libtmux .session import Session
@@ -107,17 +107,11 @@ def test_capture_pane_start(session: Session) -> None:
107107 assert pane_contents == '$ printf "%s"\n $'
108108 pane .send_keys ("clear -x" , literal = True , suppress_history = False )
109109
110- def wait_until_pane_cleared () -> bool :
111- pane_contents = "\n " .join (pane .capture_pane ())
112- return "clear -x" not in pane_contents
110+ # Using the waiter functionality to wait for the pane to be cleared
111+ expect (pane ).wait_for_predicate (lambda lines : "clear -x" not in "\n " .join (lines ))
113112
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 == "$"
119-
120- retry_until (pane_contents_shell_prompt , 1 , raises = True )
113+ # Using the waiter functionality to wait for shell prompt
114+ expect (pane ).wait_for_exact_text ("$" )
121115
122116 pane_contents_history_start = pane .capture_pane (start = - 2 )
123117 assert pane_contents_history_start [0 ] == '$ printf "%s"'
@@ -126,11 +120,9 @@ def pane_contents_shell_prompt() -> bool:
126120
127121 pane .send_keys ("" )
128122
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 )
123+ # Using the waiter functionality to verify content
124+ result = expect (pane ).with_line_range (1 , None ).wait_for_exact_text ("$" )
125+ assert result .success
134126
135127
136128def test_capture_pane_end (session : Session ) -> None :
0 commit comments