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, session_name=None, kill_session=False, attach=False, start_directory=None, window_name=None, window_command=None, x=None, y=None, environment=None, *args, detach_others=None, no_size=None, client_flags=None, **kwargs)¶libtmux.test.temporary.temp_session(server, session_name=None, kill_session=False, attach=False, start_directory=None, window_name=None, window_command=None, x=None, y=None, environment=None, *args, detach_others=None, no_size=None, client_flags=None, **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()kill_session (
bool)attach (
bool)start_directory (
StrPath|None)
- 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, window_name=None, *, start_directory=None, attach=False, window_index='', window_shell=None, environment=None, direction=None, target_window=None, kill_existing=None, select_existing=None)¶libtmux.test.temporary.temp_window(session, window_name=None, *, start_directory=None, attach=False, window_index='', window_shell=None, environment=None, direction=None, target_window=None, kill_existing=None, select_existing=None)¶
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)kwargs (
dict) – Keyword arguments passed intoSession.new_window()start_directory (
StrPath|None)attach (
bool)window_index (
str)direction (
WindowDirection|None)
- 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_...)))