Skip to content

fixtures

tmux(tmpdir_factory, request, pytestconfig, _tmux_server, tmux_session_config, tmux_assertion_config)

Fixture intended to be used with tmux tests

Scope: function

Returns:

Type Description
Generator[TmuxClient, None, None]

A pytest_tmux.client.TmuxClient object

Source code in pytest_tmux/fixtures.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@pytest.fixture()
def tmux(
    tmpdir_factory: pytest.TempdirFactory,
    request: pytest.FixtureRequest,
    pytestconfig: pytest.Config,
    _tmux_server: TmuxClient,
    tmux_session_config: Dict[str, Union[str, int]],
    tmux_assertion_config: Dict[str, Union[str, int]],
) -> Generator[TmuxClient, None, None]:
    """
    Fixture intended to be used with tmux tests

    Scope: function

    Returns:
        A [pytest_tmux.client.TmuxClient][pytest_tmux.client.TmuxClient] object
    """

    tmux_client = TmuxClient(
        request=request,
        pytestconfig=pytestconfig,
        tmpdir_factory=tmpdir_factory,
        server=_tmux_server.server,
        server_cfg_fixture=_tmux_server._server_cfg_fixture,
        session_cfg_fixture=tmux_session_config,
        assertion_cfg_fixture=tmux_assertion_config,
    )

    yield tmux_client

    if tmux_client:
        if tmux_client.sessions > 0:
            tmux_client.debug(
                """
                Closing session
                """
            )
            tmux_client.session.kill_session()

tmux_assertion_config()

Fixture intended to be override by the user to update default tmux assertion config

Scope: function

Returns:

Type Description
Dict[str, Union[str, int]]

a dictionnary containing args for :

Source code in pytest_tmux/fixtures.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@pytest.fixture()
def tmux_assertion_config() -> Dict[str, Union[str, int]]:
    """
    Fixture intended to be override by the user to update default tmux assertion config

    Scope: function

    Returns:
        a dictionnary containing args for :

          - [pytest_tmux.client.TmuxClient.screen][pytest_tmux.client.TmuxClient.screen]
          - [pytest_tmux.client.TmuxClient.row][pytest_tmux.client.TmuxClient.row]
    """
    return {}

tmux_server_config()

Fixture intended to be override by the user to update default tmux server config

Scope : session

Returns:

Type Description
Dict[str, Union[str, int]]

a dictionnary containing args for libtmux.server.Server

Source code in pytest_tmux/fixtures.py
13
14
15
16
17
18
19
20
21
22
23
@pytest.fixture(scope="session")
def tmux_server_config() -> Dict[str, Union[str, int]]:
    """
    Fixture intended to be override by the user to update default tmux server config

    Scope : session

    Returns:
        a dictionnary containing args for libtmux.server.Server
    """
    return {}

tmux_session_config()

Fixture intended to be override by the user to update default tmux session config.

Scope: function

Returns:

Type Description
Dict[str, Union[str, int]]

a dictionnary containing args for libtmux.server.Server.new_session

Source code in pytest_tmux/fixtures.py
26
27
28
29
30
31
32
33
34
35
36
37
@pytest.fixture()
def tmux_session_config() -> Dict[str, Union[str, int]]:
    """
    Fixture intended to be override by the user to update default tmux session
    config.

    Scope: function

    Returns:
        a dictionnary containing args for libtmux.server.Server.new_session
    """
    return {}