# libtmux.pytest_plugin.control_mode

- **Module:** libtmux.pytest_plugin
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/pytest_plugin.py#L301
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-pytest_plugin-control_mode/

```
libtmux.pytest_plugin.control_mode(
    server: Server, session: Session
) -> t.Callable[[], ControlMode]
```

Return :class:`ControlMode` context manager factory.

Returns a callable that creates :class:`ControlMode` context managers
bound to the test's server and session. Use as a context manager to
spawn a control-mode tmux client.

While the control-mode client is active, ``Server.list_clients()``
will include it.

## Examples

```python
>>> from libtmux._internal.control_mode import ControlMode
>>> def test_example(control_mode):
...     with control_mode() as ctl:
...         assert ctl.client_name != ''
```

## Parameters

- `server` (`Server`)
- `session` (`Session`)
