Skip to content

Commit 87153fd

Browse files
committed
tests(pytest_plugin): Add session doctest example
1 parent 0d4acff commit 87153fd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/libtmux/pytest_plugin.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,24 @@ def fin() -> None:
122122

123123
@pytest.fixture(scope="function")
124124
def session(request: pytest.FixtureRequest, server: Server) -> "Session":
125-
"""Returns a new, temporary :class:`libtmux.Session`"""
125+
"""Returns a new, temporary :class:`libtmux.Session`
126+
127+
>>> from libtmux import Session
128+
129+
>>> def test_example(session: "Session"):
130+
... assert isinstance(session.name, str)
131+
... assert session.name.startswith('libtmux_')
132+
... window = session.new_window(window_name='new one')
133+
... assert window.name == 'new one'
134+
135+
>>> import inspect
136+
137+
>>> test_mod = pytester.makepyfile(whatever=inspect.getsource(test_example))
138+
>>> result = pytester.inline_run(str(test_mod), '--disable-warnings')
139+
===...
140+
141+
>>> result.assertoutcome(passed=1)
142+
"""
126143
session_name = "tmuxp"
127144

128145
if not server.has_session(session_name):

0 commit comments

Comments
 (0)