Fixture Reference¶
libtmux pytest plugin.
- libtmux.pytest_plugin.home_path(tmp_path_factory)[source]¶
Temporary /home/ path.
- Return type:
- Parameters:
tmp_path_factory (TempPathFactory)
- libtmux.pytest_plugin.home_user_name()[source]¶
Return default username to set for
user_path()fixture.- Return type:
- libtmux.pytest_plugin.user_path(home_path, home_user_name)[source]¶
Ensure and return temporary user directory.
Used by:
config_file(),zshrc()Note: You will need to set the home directory, see Setting a temporary home directory.
- libtmux.pytest_plugin.zshrc(user_path)[source]¶
Suppress ZSH default message.
Needs a startup file .zshenv, .zprofile, .zshrc, .zlogin.
- libtmux.pytest_plugin.config_file(user_path)[source]¶
Return fixture for
.tmux.confconfiguration.base-index -g 1
These guarantee pane and windows targets can be reliably referenced and asserted.
Note: You will need to set the home directory, see Setting a temporary home directory.
- libtmux.pytest_plugin.clear_env(monkeypatch)[source]¶
Clear out any unnecessary environment variables that could interrupt tests.
tmux show-environment tests were being interrupted due to a lot of crazy env vars.
- Return type:
- Parameters:
monkeypatch (MonkeyPatch)
- libtmux.pytest_plugin.server(request, monkeypatch, config_file)[source]¶
Return new, temporary
libtmux.Server.- Return type:
- Parameters:
request (FixtureRequest)
monkeypatch (MonkeyPatch)
config_file (Path)
>>> from libtmux.server import Server
>>> def test_example(server: Server) -> None: ... assert isinstance(server, Server) ... session = server.new_session('my session') ... assert len(server.sessions) == 1 ... assert [session.name.startswith('my') for session in server.sessions]
- libtmux.pytest_plugin.session_params()[source]¶
Return new, temporary
libtmux.Session.>>> import pytest >>> from libtmux.session import Session
>>> @pytest.fixture ... def session_params(session_params): ... return { ... 'x': 800, ... 'y': 600, ... }
>>> def test_example(session: "Session") -> None: ... assert isinstance(session.name, str) ... assert session.name.startswith('libtmux_') ... window = session.new_window(window_name='new one') ... assert window.name == 'new one'
- libtmux.pytest_plugin.session(request, session_params, server)[source]¶
Return new, temporary
libtmux.Session.- Return type:
Session
- Parameters:
request (pytest.FixtureRequest)
server (Server)
>>> from libtmux.session import Session
>>> def test_example(session: "Session") -> None: ... assert isinstance(session.name, str) ... assert session.name.startswith('libtmux_') ... window = session.new_window(window_name='new one') ... assert window.name == 'new one'
- libtmux.pytest_plugin.TestServer(request)[source]¶
Create a temporary tmux server that cleans up after itself.
This is similar to the server pytest fixture, but can be used outside of pytest. The server will be killed when the test completes.
- Return type:
- Returns:
A factory function that returns a Server with a unique socket_name
- Return type:
- Parameters:
request (FixtureRequest)
Examples
>>> server = Server() # Create server instance >>> server.new_session() Session($... ...) >>> server.is_alive() True >>> # Each call creates a new server with unique socket >>> server2 = Server() >>> server2.socket_name != server.socket_name True