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)
¶
function[source]
function[source]
libtmux.test.temporary.temp_session(server, *args, **kwargs)
¶

Return a context manager with a temporary session.

If no session_name is entered, get_test_session_name() will make an unused session name.

The session will destroy itself upon closing with Session.session().

Parameters:
Yields:

libtmux.Session – Temporary session

Return type:

Generator[Session, Any, Any]

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)
¶
function[source]
function[source]
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_name is entered, get_test_window_name() will make an unused window name.

Parameters:
Yields:

libtmux.Window – temporary window

Return type:

Generator[Window, Any, Any]

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_...)))