Skip to content

Commit 32cc6cc

Browse files
committed
chore(rebase): Fix conflict-resolution regressions
why: The rebase onto current master left an orphaned pre-engine code block and stale variable names in Server.raise_if_dead, plus an unused formats import. what: - Use the resolved tmux binary in the CalledProcessError command - Drop the unreachable subprocess.check_call block orphaned inside _build_server_args - Remove the unused libtmux.formats import
1 parent 1ad4164 commit 32cc6cc

2 files changed

Lines changed: 67 additions & 7 deletions

File tree

docs/pytest-plugin/index.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
myst:
3+
html_meta:
4+
description: "libtmux pytest plugin for testing tmux applications with pytest"
5+
keywords: "tmux, pytest, plugin, testing, libtmux"
6+
---
7+
8+
(pytest_plugin)=
9+
10+
# tmux `pytest` plugin
11+
12+
```{toctree}
13+
:hidden:
14+
:maxdepth: 2
15+
16+
getting-started
17+
fixtures
18+
usage-examples
19+
advanced-techniques
20+
```
21+
22+
libtmux provides pytest fixtures for tmux, making it easy to test tmux-related functionality with complete isolation. The plugin automatically manages setup and teardown of independent tmux servers, sessions, windows, and panes.
23+
24+
```{admonition} Connect with us!
25+
:class: seealso
26+
27+
Do you want more flexibility? Correctness? Power? Defaults changed? [Connect with us](https://github.com/tmux-python/libtmux/discussions) on the tracker. We want to know your use case and won't stabilize APIs until we're sure everything is by the book.
28+
```
29+
30+
## Benefits at a glance
31+
32+
- **Isolated Testing Environment**: Each test gets a fresh tmux server that won't interfere with other tests
33+
- **Automatic Cleanup**: Servers, sessions, and other resources are automatically cleaned up after tests
34+
- **Simplified Setup**: Common fixtures for server, session, window, and pane management
35+
- **Reliable Testing**: Consistent environment for reproducible test results
36+
- **Custom Configuration**: Easily test with different tmux configurations and settings
37+
38+
## Quick installation
39+
40+
Install `libtmux` via the Python package manager of your choice:
41+
42+
```{code-block} console
43+
$ pip install libtmux
44+
```
45+
46+
The pytest plugin will be automatically detected by pytest, and the fixtures will be available in your test environment.
47+
48+
## See real-world examples
49+
50+
View libtmux's own [tests/](https://github.com/tmux-python/libtmux/tree/master/tests) as well as tmuxp's [tests/](https://github.com/tmux-python/tmuxp/tree/master/tests) for real-world examples.
51+
52+
For detailed code examples and usage patterns, refer to the {ref}`usage-examples` page.
53+
54+
## Module reference
55+
56+
```{module} libtmux.pytest_plugin
57+
```
58+
59+
```{eval-rst}
60+
.. automodule:: libtmux.pytest_plugin
61+
:members:
62+
:inherited-members:
63+
:private-members:
64+
:show-inheritance:
65+
:member-order: bysource

src/libtmux/server.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import typing as t
1717
import warnings
1818

19-
from libtmux import exc, formats
19+
from libtmux import exc
2020
from libtmux._internal.engines.base import ServerContext
2121
from libtmux._internal.engines.subprocess_engine import SubprocessEngine
2222
from libtmux._internal.env import socket_path_from_env
@@ -362,7 +362,7 @@ def raise_if_dead(self) -> None:
362362
if proc.returncode is not None and proc.returncode != 0:
363363
raise subprocess.CalledProcessError(
364364
returncode=proc.returncode,
365-
cmd=[tmux_bin, *server_args, "list-sessions"],
365+
cmd=[resolved, *server_args, "list-sessions"],
366366
)
367367

368368
#
@@ -379,11 +379,6 @@ def _build_server_args(self) -> list[str]:
379379
server_args.append(f"-f{self.config_file}")
380380
return server_args
381381

382-
try:
383-
subprocess.check_call([resolved, *cmd_args])
384-
except FileNotFoundError:
385-
raise exc.TmuxCommandNotFound from None
386-
387382
def _probe_server(self) -> int:
388383
"""Check server liveness without bootstrapping control mode."""
389384
tmux_bin = shutil.which("tmux")

0 commit comments

Comments
 (0)