File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,28 @@ def test_my_flow(server, engine_name):
162162` TestServer ` also respects the selected engine. Control mode is experimental and
163163its APIs may change between releases.
164164
165+ ### Control sandbox fixture (experimental)
166+
167+ Use `` control_sandbox `` when you need a hermetic control-mode server for a test:
168+
169+ ``` python
170+ import typing as t
171+ import pytest
172+ from libtmux.server import Server
173+
174+ @pytest.mark.engines ([" control" ])
175+ def test_control_sandbox (control_sandbox : t.ContextManager[Server]):
176+ with control_sandbox as server:
177+ session = server.new_session(session_name = " sandbox" , attach = False )
178+ out = server.cmd(" display-message" , " -p" , " hi" )
179+ assert out.stdout == [" hi" ]
180+ ```
181+
182+ The fixture:
183+ - Spins up a unique socket name and isolates `` HOME `` / `` TMUX_TMPDIR ``
184+ - Clears inherited `` TMUX `` so it never attaches to the user's server
185+ - Uses `` ControlModeEngine `` and cleans up the server on exit
186+
165187## Fixtures
166188
167189``` {eval-rst}
You can’t perform that action at this time.
0 commit comments