Skip to content

Commit 343c62b

Browse files
committed
tests(doctests): Pane and capture_pane
1 parent 976bbbe commit 343c62b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

libtmux/pane.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ class Pane(TmuxMappingObject):
3636
----------
3737
window : :class:`Window`
3838
39+
Examples
40+
--------
41+
>>> pane
42+
Pane(%1 Window(@1 1:...sh, Session($1 ...)))
43+
44+
>>> pane in window.panes
45+
True
46+
47+
>>> pane.window
48+
Window(@1 1:...sh, Session($1 ...))
49+
50+
>>> pane.session
51+
Session($1 ...)
52+
3953
Notes
4054
-----
4155
@@ -119,8 +133,7 @@ def send_keys(
119133
suppress_history: t.Optional[bool] = True,
120134
literal: t.Optional[bool] = False,
121135
) -> None:
122-
"""
123-
``$ tmux send-keys`` to the pane.
136+
r"""``$ tmux send-keys`` to the pane.
124137
125138
A leading space character is added to cmd to avoid polluting the
126139
user's history.
@@ -135,6 +148,22 @@ def send_keys(
135148
Don't add these keys to the shell history, default True.
136149
literal : bool, optional
137150
Send keys literally, default True.
151+
152+
Examples
153+
--------
154+
>>> pane = window.split_window(shell='sh')
155+
>>> pane.capture_pane()
156+
['$']
157+
158+
>>> pane.send_keys('echo "Hello world"', suppress_history=False, enter=True)
159+
160+
>>> pane.capture_pane()
161+
['$ echo "Hello world"', 'Hello world', '$']
162+
163+
>>> print('\n'.join(pane.capture_pane())) # doctest: +NORMALIZE_WHITESPACE
164+
$ echo "Hello world"
165+
Hello world
166+
$
138167
"""
139168
prefix = " " if suppress_history else ""
140169

0 commit comments

Comments
 (0)