8
8
9
9
import pytest
10
10
11
+ from libtmux ._internal .waiter import expect
11
12
from libtmux .common import has_gte_version , has_lt_version , has_lte_version
12
13
from libtmux .constants import PaneDirection , ResizeAdjustmentDirection
13
- from libtmux .test .retry import retry_until
14
14
15
15
if t .TYPE_CHECKING :
16
16
from libtmux .session import Session
@@ -107,17 +107,11 @@ def test_capture_pane_start(session: Session) -> None:
107
107
assert pane_contents == '$ printf "%s"\n $'
108
108
pane .send_keys ("clear -x" , literal = True , suppress_history = False )
109
109
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 ))
113
112
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 ("$" )
121
115
122
116
pane_contents_history_start = pane .capture_pane (start = - 2 )
123
117
assert pane_contents_history_start [0 ] == '$ printf "%s"'
@@ -126,11 +120,9 @@ def pane_contents_shell_prompt() -> bool:
126
120
127
121
pane .send_keys ("" )
128
122
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
134
126
135
127
136
128
def test_capture_pane_end (session : Session ) -> None :
0 commit comments