Skip to content

Commit 241d3a0

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

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

libtmux/pane.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ class Pane(TmuxMappingObject):
3636
----------
3737
window : :class:`Window`
3838
39+
Examples
40+
--------
41+
>>> window = session.attached_window
42+
>>> window
43+
Window(@1 1:...sh, Session($1 ...))
44+
45+
>>> pane = window.attached_pane
46+
>>> pane
47+
Pane(%1 Window(@1 1:...sh, Session($1 ...)))
48+
49+
>>> pane in window.panes
50+
True
51+
3952
Notes
4053
-----
4154
@@ -119,8 +132,7 @@ def send_keys(
119132
suppress_history: t.Optional[bool] = True,
120133
literal: t.Optional[bool] = False,
121134
) -> None:
122-
"""
123-
``$ tmux send-keys`` to the pane.
135+
r"""``$ tmux send-keys`` to the pane.
124136
125137
A leading space character is added to cmd to avoid polluting the
126138
user's history.
@@ -135,6 +147,22 @@ def send_keys(
135147
Don't add these keys to the shell history, default True.
136148
literal : bool, optional
137149
Send keys literally, default True.
150+
151+
Examples
152+
--------
153+
>>> pane = window.split_window(shell='sh')
154+
>>> pane.capture_pane()
155+
['$']
156+
157+
>>> pane.send_keys('echo "Hello world"', suppress_history=False, enter=True)
158+
159+
>>> pane.capture_pane()
160+
['$ echo "Hello world"', 'Hello world', '$']
161+
162+
>>> print('\n'.join(pane.capture_pane())) # doctest: +NORMALIZE_WHITESPACE
163+
$ echo "Hello world"
164+
Hello world
165+
$
138166
"""
139167
prefix = " " if suppress_history else ""
140168

0 commit comments

Comments
 (0)