@@ -221,14 +221,36 @@ class PaneContentWaiter:
221
221
... .wait_for_text("hello world")
222
222
... )
223
223
224
+ Wait for text with a longer timeout:
225
+
226
+ >>> pane.send_keys("echo 'Operation completed'", enter=True)
227
+ >>> try:
228
+ ... result = (
229
+ ... expect(pane)
230
+ ... .with_timeout(1.0) # Reduce timeout for faster doctest execution
231
+ ... .without_raising() # Don't raise exceptions
232
+ ... .wait_for_text("Operation completed")
233
+ ... )
234
+ ... print(f"Result success: {result.success}")
235
+ ... except Exception as e:
236
+ ... print(f"Caught exception: {type(e).__name__}: {e}")
237
+ Result success: True
238
+
224
239
Wait for regex pattern:
225
240
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
- ... )
241
+ >>> pane.send_keys("echo 'Process 0 completed.'", enter=True)
242
+ >>> try:
243
+ ... result = (
244
+ ... PaneContentWaiter(pane)
245
+ ... .with_timeout(1.0) # Reduce timeout for faster doctest execution
246
+ ... .without_raising() # Don't raise exceptions
247
+ ... .wait_for_regex(r"Process \d+ completed")
248
+ ... )
249
+ ... # Print debug info about the result for doctest
250
+ ... print(f"Result success: {result.success}")
251
+ ... except Exception as e:
252
+ ... print(f"Caught exception: {type(e).__name__}: {e}")
253
+ Result success: True
232
254
233
255
Custom predicate:
234
256
@@ -494,21 +516,32 @@ def expect(pane: Pane) -> PaneContentWaiter:
494
516
495
517
Wait for text with a longer timeout:
496
518
497
- >>> pane.send_keys("echo 'Operation completed", enter=True)
498
- >>> result = (
499
- ... expect(pane)
500
- ... .with_timeout(10.0)
501
- ... .wait_for_text("Operation completed")
502
- ... )
503
- >>>
519
+ >>> pane.send_keys("echo 'Operation completed'", enter=True)
520
+ >>> try:
521
+ ... result = (
522
+ ... expect(pane)
523
+ ... .with_timeout(1.0) # Reduce timeout for faster doctest execution
524
+ ... .without_raising() # Don't raise exceptions
525
+ ... .wait_for_text("Operation completed")
526
+ ... )
527
+ ... print(f"Result success: {result.success}")
528
+ ... except Exception as e:
529
+ ... print(f"Caught exception: {type(e).__name__}: {e}")
530
+ Result success: True
504
531
505
532
Wait for a regex match without raising exceptions on timeout:
506
533
>>> pane.send_keys("echo 'Process 19 completed'", enter=True)
507
- >>> result = (
508
- ... expect(pane)
509
- ... .without_raising()
510
- ... .wait_for_regex(r"Process \d+ completed")
511
- ... )
534
+ >>> try:
535
+ ... result = (
536
+ ... expect(pane)
537
+ ... .with_timeout(1.0) # Reduce timeout for faster doctest execution
538
+ ... .without_raising() # Don't raise exceptions
539
+ ... .wait_for_regex(r"Process \d+ completed")
540
+ ... )
541
+ ... print(f"Result success: {result.success}")
542
+ ... except Exception as e:
543
+ ... print(f"Caught exception: {type(e).__name__}: {e}")
544
+ Result success: True
512
545
"""
513
546
return PaneContentWaiter (pane )
514
547
0 commit comments