Skip to content

Commit ac631e0

Browse files
committed
doctest(Pane) send_keys
1 parent 6b8ab3e commit ac631e0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/libtmux/pane.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,30 @@ def send_keys(
371371
372372
Examples
373373
--------
374-
>>> pane = window.split(shell='sh')
374+
>>> import shutil
375+
>>> pane = window.split(
376+
... shell=f"{shutil.which('env')} PROMPT_COMMAND='' PS1='READY>' sh")
377+
>>> from libtmux.test.retry import retry_until
378+
>>> def wait_for_prompt() -> bool:
379+
... try:
380+
... pane_contents = "\n".join(pane.capture_pane())
381+
... return "READY>" in pane_contents and len(pane_contents.strip()) > 0
382+
... except Exception:
383+
... return False
384+
>>> retry_until(wait_for_prompt, 2, raises=True)
385+
True
375386
>>> pane.capture_pane()
376-
['$']
387+
['READY>']
377388
378389
>>> pane.send_keys('echo "Hello world"', enter=True)
379390
380391
>>> pane.capture_pane()
381-
['$ echo "Hello world"', 'Hello world', '$']
392+
['READY>echo "Hello world"', 'Hello world', 'READY>']
382393
383394
>>> print('\n'.join(pane.capture_pane())) # doctest: +NORMALIZE_WHITESPACE
384-
$ echo "Hello world"
395+
READY>echo "Hello world"
385396
Hello world
386-
$
397+
READY>
387398
"""
388399
prefix = " " if suppress_history else ""
389400

0 commit comments

Comments
 (0)