|
| 1 | +(pytest_plugin)= |
| 2 | + |
| 3 | +# `pytest` plugin |
| 4 | + |
| 5 | +Testing tmux with libtmux |
| 6 | + |
| 7 | +```{seealso} Using libtmux? |
| 8 | +
|
| 9 | +Do you want more flexbility? Correctness? Power? Defaults changed? [Connect with us] on the tracker, we want to know |
| 10 | +your case, we won't stabilize APIs until we're sure everything is by the book. |
| 11 | +
|
| 12 | +[connect with us]: https://github.com/tmux-python/libtmux/discussions |
| 13 | +
|
| 14 | +``` |
| 15 | + |
| 16 | +```{module} libtmux.pytest_plugin |
| 17 | +
|
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +Install `libtmux` via the python package manager of your choosing, e.g. |
| 23 | + |
| 24 | +```console |
| 25 | +$ pip install libtmux |
| 26 | +``` |
| 27 | + |
| 28 | +The pytest plugin will automatically be detected via pytest, and the fixtures will be added. |
| 29 | + |
| 30 | +## Fixtures |
| 31 | + |
| 32 | +`pytest-tmux` works through providing {ref}`pytest fixtures <pytest:fixtures-api>` - so read up on |
| 33 | +those! |
| 34 | + |
| 35 | +The plugin's fixtures guarantee a fresh, headless `tmux(1)` server, session, window, or pane is |
| 36 | +passed into your test. |
| 37 | + |
| 38 | +## Autoused fixtures |
| 39 | + |
| 40 | +These are fixtures are automatically used when the plugin is enabled and `pytest` is ran. |
| 41 | + |
| 42 | +- Creating temporary, test directories for: |
| 43 | + - `/home/` ({func}`home_path`) |
| 44 | + - `/home/${user}` ({func}`user_path`) |
| 45 | +- Setting default .zshrc ({func}`zshrc`) |
| 46 | +- Default `.tmux.conf` configuration with these settings ({func}`config_file`): |
| 47 | + |
| 48 | + - `base-index -g 1` |
| 49 | + - `pane-base-index -g 1` |
| 50 | + |
| 51 | + This are set to ensure panes and windows can be reliably referenced and asserted. |
| 52 | + |
| 53 | +## See examples |
| 54 | + |
| 55 | +View libtmux's own [tests/](https://github.com/tmux-python/libtmux/tree/master/tests) as well as |
| 56 | +tmuxp's [tests/](https://github.com/tmux-python/tmuxp/tree/master/tests). |
| 57 | + |
| 58 | +## API reference |
| 59 | + |
| 60 | +```{eval-rst} |
| 61 | +.. autoapimodule:: libtmux.pytest_plugin |
| 62 | + :members: |
| 63 | + :inherited-members: |
| 64 | + :private-members: |
| 65 | + :show-inheritance: |
| 66 | + :member-order: bysource |
| 67 | + :exclude-members: Server, TEST_SESSION_PREFIX, get_test_session_name, |
| 68 | + namer, logger |
| 69 | +``` |
0 commit comments