You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+119
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,125 @@ if not session:
111
111
print(f"Connected to: {session}")
112
112
```
113
113
114
+
## Testable Examples
115
+
116
+
The following examples can be run as doctests using `py.test --doctest-modules README.md`. They assume that `server`, `session`, `window`, and `pane` objects have already been created.
117
+
118
+
### Working with Server Objects
119
+
120
+
```python
121
+
>>># Verify server is running
122
+
>>> server.is_alive()
123
+
True
124
+
125
+
>>># Check server has sessions attribute
126
+
>>>hasattr(server, 'sessions')
127
+
True
128
+
129
+
>>># List all tmux sessions
130
+
>>>isinstance(server.sessions, list)
131
+
True
132
+
>>>len(server.sessions) >0
133
+
True
134
+
135
+
>>># At least one session should exist
136
+
>>>len([s for s in server.sessions if s.session_id]) >0
137
+
True
138
+
```
139
+
140
+
### Session Operations
141
+
142
+
```python
143
+
>>># Check session attributes
144
+
>>>isinstance(session.session_id, str) and session.session_id.startswith('$')
145
+
True
146
+
147
+
>>># Verify session name exists
148
+
>>>isinstance(session.session_name, str)
149
+
True
150
+
>>>len(session.session_name) >0
151
+
True
152
+
153
+
>>># Session should have windows
154
+
>>>isinstance(session.windows, list)
155
+
True
156
+
>>>len(session.windows) >0
157
+
True
158
+
159
+
>>># Get active window
160
+
>>> session.active_window isnotNone
161
+
True
162
+
```
163
+
164
+
### Window Management
165
+
166
+
```python
167
+
>>># Window has an ID
168
+
>>>isinstance(window.window_id, str) and window.window_id.startswith('@')
169
+
True
170
+
171
+
>>># Window belongs to a session
172
+
>>>hasattr(window, 'session') and window.session isnotNone
173
+
True
174
+
175
+
>>># Window has panes
176
+
>>>isinstance(window.panes, list)
177
+
True
178
+
>>>len(window.panes) >0
179
+
True
180
+
181
+
>>># Window has a name (could be empty but should be a string)
182
+
>>>isinstance(window.window_name, str)
183
+
True
184
+
```
185
+
186
+
### Pane Manipulation
187
+
188
+
```python
189
+
>>># Pane has an ID
190
+
>>>isinstance(pane.pane_id, str) and pane.pane_id.startswith('%')
191
+
True
192
+
193
+
>>># Pane belongs to a window
194
+
>>>hasattr(pane, 'window') and pane.window isnotNone
195
+
True
196
+
197
+
>>># Test sending commands
198
+
>>> pane.send_keys('echo "Hello from libtmux test"', enter=True)
199
+
>>>import time
200
+
>>> time.sleep(1) # Longer wait to ensure command execution
0 commit comments