Temporary Objects¶
Context managers for temporary tmux objects (sessions, windows).
Temporary object helpers for libtmux and downstream libtmux libraries.
-
libtmux.test.temporary.temp_session(server, *args, **kwargs)¶libtmux.test.temporary.temp_session(server, *args, **kwargs)¶
Return a context manager with a temporary session.
If no
session_nameis entered,get_test_session_name()will make an unused session name.The session will destroy itself upon closing with
Session.session().- Parameters:
server (
libtmux.Server)args (
list) – Arguments passed intoServer.new_session()kwargs (
dict) – Keyword arguments passed intoServer.new_session()
- Yields:
libtmux.Session– Temporary session- Return type:
Examples
>>> with temp_session(server) as session: ... session.new_window(window_name='my window') Window(@3 2:my window, Session($... ...))
-
libtmux.test.temporary.temp_window(session, *args, **kwargs)¶libtmux.test.temporary.temp_window(session, *args, **kwargs)¶
Return a context manager with a temporary window.
The window will destroy itself upon closing with
window. kill().If no
window_nameis entered,get_test_window_name()will make an unused window name.- Parameters:
session (
libtmux.Session)args (
list) – Arguments passed intoSession.new_window()kwargs (
dict) – Keyword arguments passed intoSession.new_window()
- Yields:
libtmux.Window– temporary window- Return type:
Examples
>>> with temp_window(session) as window: ... window Window(@2 2:... Session($1 libtmux_...))
>>> with temp_window(session) as window: ... window.split() Pane(%4 Window(@3 2:libtmux_..., Session($1 libtmux_...)))