Skip to content

Commit c2d5368

Browse files
committed
docs(pytest_plugin) Add TestServer
1 parent 135add8 commit c2d5368

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/pytest-plugin/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ def test_something(session):
9393

9494
The above will assure the libtmux session launches with `-x 800 -y 600`.
9595

96+
(temp_server)=
97+
98+
### Creating temporary servers
99+
100+
If you need multiple independent tmux servers in your tests, the {func}`TestServer fixture <libtmux.pytest_plugin.TestServer>` provides a factory that creates servers with unique socket names. Each server is automatically cleaned up when the test completes.
101+
102+
```python
103+
def test_something(TestServer):
104+
Server = TestServer() # Get unique partial'd Server
105+
server = Server() # Create server instance
106+
107+
session = server.new_session()
108+
assert server.is_alive()
109+
```
110+
111+
You can also use it with custom configurations, similar to the {ref}`server fixture <Setting a tmux configuration>`:
112+
113+
```python
114+
def test_with_config(TestServer, tmp_path):
115+
config_file = tmp_path / "tmux.conf"
116+
config_file.write_text("set -g status off")
117+
118+
Server = TestServer()
119+
server = Server(config_file=str(config_file))
120+
```
121+
122+
This is particularly useful when testing interactions between multiple tmux servers or when you need to verify behavior across server restarts.
123+
96124
(set_home)=
97125

98126
### Setting a temporary home directory

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy