Skip to content

Commit 6a88af7

Browse files
committed
!squash waiter
1 parent c260e4f commit 6a88af7

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

src/libtmux/test/waiter.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ class PaneContentWaiter:
200200
>>> hasattr(waiter, 'wait_until_ready')
201201
True
202202
203-
>>> # Real-world usage examples
204-
>>> # A functional example: send text to the pane and wait for it
203+
A functional example: send text to the pane and wait for it:
204+
205205
>>> # First, send "hello world" to the pane
206206
>>> pane.send_keys("echo 'hello world'", enter=True)
207207
>>>
@@ -212,27 +212,42 @@ class PaneContentWaiter:
212212
>>> "hello world" in result.matched_content
213213
True
214214
>>>
215-
>>> # Basic usage (showing API only, other examples)
216-
>>> # result = PaneContentWaiter(pane).wait_for_text("other example")
217-
>>>
218-
>>> # With options
219-
>>> # result = (
220-
>>> # PaneContentWaiter(pane)
221-
>>> # .with_timeout(10.0)
222-
>>> # .wait_for_exact_text("completed successfully")
223-
>>> # )
224-
>>>
225-
>>> # Wait for regex pattern
226-
>>> # result = (
227-
>>> # PaneContentWaiter(pane)
228-
>>> # .with_timeout(10.0)
229-
>>> # .wait_for_regex(r"Process \d+ completed")
230-
>>> # )
231-
>>>
232-
>>> # Custom predicate
215+
216+
With options:
217+
218+
>>> result = (
219+
... PaneContentWaiter(pane)
220+
... .with_timeout(5.0)
221+
... .wait_for_text("hello world")
222+
... )
223+
224+
Wait for regex pattern:
225+
226+
>>> pane.send_keys("echo 'Process 0 completed.", enter=True)
227+
>>> result = (
228+
... PaneContentWaiter(pane)
229+
... .with_timeout(10.0)
230+
... .wait_for_regex(r"Process \d+ completed")
231+
... )
232+
233+
Custom predicate:
234+
235+
>>> pane.send_keys("echo 'We are ready!'", enter=True)
233236
>>> def is_ready(content):
234237
... return any("ready" in line.lower() for line in content)
235-
>>> # result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
238+
>>> result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
239+
240+
Timeout:
241+
242+
>>> try:
243+
... result = (
244+
... PaneContentWaiter(pane)
245+
... .with_timeout(0.01)
246+
... .wait_for_exact_text("hello world")
247+
... )
248+
... except WaitTimeout:
249+
... print('No exact match')
250+
No exact match
236251
"""
237252

238253
def __init__(self, pane: Pane) -> None:

0 commit comments

Comments
 (0)