pytest-tmux
A pytest plugin that enables tmux driven tests
This plugin is intend to help users who want to test interrative cli.
When using tmux fixture it basically :
- creates a tmux server (socket created in pytest tmpdir)
- creates a session automatically
- attach to the window automatically
- attach to the pane automatically
Warnings
Until a stable release, it is greatly encouraged to specify a strict version if you use this tool in your CI since it is in its early development and could be greatly changed between version.
Docs
https://pytest-tmux.readthedocs.io/
Features
- Enable tmux driven tests
- Enable screen assertion with retry
- Enable row assertion with retry
- Allow to debug tests interactively
Requirements
- python >= 3.7
- pytest
- tmux
Installation
You can install "pytest-tmux" via pip from PyPI:
$ pip install pytest-tmux
Configuration capabilities
Configuration could be set on different level (in order of precedence):
- Server
- by overriding tmux_server_config (scope='session') fixture
- env var
- cli args (see --tmux-* switch with pytest --help)
- Session
- by overriding tmux_session_config fixture
- at the test level with tmux_session_cfg marker
- dynamically inside test with
tmux.config.session - env var
- cli args (see --tmux-* switch with pytest --help)
- Assertion
- by overriding tmux_assertion_config fixture
- at the test level with tmux_assertion_cfg marker
- dynamically inside test with
tmux.config.session - when calling
tmux.screen() / tmux.row()withtimeout/delayargument - env var
- cli args (see --tmux-* switch with pytest --help)
Usage
Basic example
import pytest
from inspect import cleandoc
def test_assert(tmux):
# Set some options before session / windows is started
tmux.config.session.window_command='env -i PS1="$ " TERM="xterm-256color" /usr/bin/env bash --norc --noprofile'
assert tmux.screen() == '$'
tmux.send_keys(r'printf " Hello World .\n\n"')
expected=r"""
$ printf " Hello World .\n\n"
Hello World .
$
"""
assert tmux.screen() == cleandoc(expected)
License
Distributed under the terms of the MIT license, "pytest-tmux" is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Release files for pytest-tmux 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_tmux-0.0.5.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_tmux-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.0 kB
Release files / pytest_tmux-0.0.5.tar.gz
| Download URL | pytest_tmux-0.0.5.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d94061bc6890cf8b0583dcbc6c74dc69ac77c63b851246a42fd7458425b1848
|
|
BLAKE2b-256 checksum How to use checksums |
7eba142e2ba6d4e5f2c841ea5bd7837df53239390b267d2a3658c3dbf69794d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.7.14 Linux/5.4.0-216-generic
|
Release files / pytest_tmux-0.0.5-py3-none-any.whl
| Download URL | pytest_tmux-0.0.5-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
799544cd2dce4294d1fe36c448c9425637d4bdb277ee0e6ffd1cb8ba377f0625
|
|
BLAKE2b-256 checksum How to use checksums |
c56fdb2107bd2d29d7a9ac0f8ba486e94ff1d39b00c54f7cc78629556acc2326
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.7.14 Linux/5.4.0-216-generic
|