@@ -29,28 +29,25 @@ def temp_session(
29
29
** kwargs : t .Any ,
30
30
) -> Generator [Session , t .Any , t .Any ]:
31
31
"""
32
- Return a context manager with a temporary session.
32
+ Provide a context manager for a temporary session, killed on exit .
33
33
34
- If no ``session_name`` is entered, :func:`get_test_session_name` will make
35
- an unused session name.
36
-
37
- The session will destroy itself upon closing with :meth:`Session.session()`.
34
+ If no ``session_name`` is specified, :func:`get_test_session_name` will
35
+ generate an unused one. The session is destroyed upon exiting the context
36
+ manager.
38
37
39
38
Parameters
40
39
----------
41
- server : :class:`libtmux.Server`
42
-
43
- Other Parameters
44
- ----------------
40
+ server : Server
41
+ The tmux server instance.
45
42
args : list
46
- Arguments passed into :meth:`Server.new_session`
43
+ Additional positional arguments for :meth:`Server.new_session`.
47
44
kwargs : dict
48
- Keyword arguments passed into :meth:`Server.new_session`
45
+ Keyword arguments for :meth:`Server.new_session`.
49
46
50
47
Yields
51
48
------
52
- :class:`libtmux. Session`
53
- Temporary session
49
+ Session
50
+ The newly created temporary session.
54
51
55
52
Examples
56
53
--------
@@ -80,37 +77,32 @@ def temp_window(
80
77
** kwargs : t .Any ,
81
78
) -> Generator [Window , t .Any , t .Any ]:
82
79
"""
83
- Return a context manager with a temporary window.
84
-
85
- The window will destroy itself upon closing with :meth:`window.
86
- kill()`.
80
+ Provide a context manager for a temporary window, killed on exit.
87
81
88
- If no ``window_name`` is entered, :func:`get_test_window_name` will make
89
- an unused window name.
82
+ If no ``window_name`` is specified, :func:`get_test_window_name` will
83
+ generate an unused one. The window is destroyed upon exiting the context
84
+ manager.
90
85
91
86
Parameters
92
87
----------
93
- session : :class:`libtmux.Session`
94
-
95
- Other Parameters
96
- ----------------
88
+ session : Session
89
+ The tmux session instance.
97
90
args : list
98
- Arguments passed into :meth:`Session.new_window`
91
+ Additional positional arguments for :meth:`Session.new_window`.
99
92
kwargs : dict
100
- Keyword arguments passed into :meth:`Session.new_window`
93
+ Keyword arguments for :meth:`Session.new_window`.
101
94
102
95
Yields
103
96
------
104
- :class:`libtmux. Window`
105
- temporary window
97
+ Window
98
+ The newly created temporary window.
106
99
107
100
Examples
108
101
--------
109
102
>>> with temp_window(session) as window:
110
103
... window
111
104
Window(@2 2:... Session($1 libtmux_...))
112
105
113
-
114
106
>>> with temp_window(session) as window:
115
107
... window.split()
116
108
Pane(%4 Window(@3 2:libtmux_..., Session($1 libtmux_...)))
@@ -121,8 +113,6 @@ def temp_window(
121
113
window_name = kwargs .pop ("window_name" )
122
114
123
115
window = session .new_window (window_name , * args , ** kwargs )
124
-
125
- # Get ``window_id`` before returning it, it may be killed within context.
126
116
window_id = window .window_id
127
117
assert window_id is not None
128
118
assert isinstance (window_id , str )
0 commit comments