# libtmux.pytest_plugin.session

- **Module:** libtmux.pytest_plugin
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/pytest_plugin.py#L224
- **Page:** https://libtmux.org/reference/py/libtmux-pytest_plugin-session/

```
libtmux.pytest_plugin.session(request: pytest.FixtureRequest, session_params: dict[str, t.Any], server: Server) -> Session
```

Return new, temporary :class:`libtmux.Session`.

>>> 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'

.. ::
    >>> locals().keys()
    dict_keys(...)

    >>> source = ''.join([e.source for e in request._pyfuncitem.dtest.examples][:3])
    >>> pytester = request.getfixturevalue('pytester')

    >>> pytester.makepyfile(**{'whatever.py': source})
    PosixPath(...)

    >>> result = pytester.runpytest('whatever.py', '--disable-warnings')
    ===...

    >>> result.assert_outcomes(passed=1)
