Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac631e0

Browse filesBrowse files
committed
doctest(Pane) send_keys
1 parent 6b8ab3e commit ac631e0
Copy full SHA for ac631e0

File tree

Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed

‎src/libtmux/pane.py

Copy file name to clipboardExpand all lines: src/libtmux/pane.py
+16-5Lines changed: 16 additions & 5 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.