@@ -27,6 +27,16 @@ class RandomStrSequence:
27
27
def __init__ (
28
28
self , characters : str = "abcdefghijklmnopqrstuvwxyz0123456789_"
29
29
) -> None :
30
+ """Create a random letter / number generator. 8 chars in length.
31
+
32
+ >>> rng = RandomStrSequence()
33
+ >>> next(rng)
34
+ '...'
35
+ >>> len(next(rng))
36
+ 8
37
+ >>> type(next(rng))
38
+ <class 'str'>
39
+ """
30
40
self .characters : str = characters
31
41
32
42
def __iter__ (self ) -> "RandomStrSequence" :
@@ -68,7 +78,6 @@ def retry_until(
68
78
69
79
Examples
70
80
--------
71
-
72
81
>>> def fn():
73
82
... p = session.attached_window.attached_pane
74
83
... p.server._update_panes()
@@ -110,6 +119,15 @@ def get_test_session_name(server: "Server", prefix: str = TEST_SESSION_PREFIX) -
110
119
-------
111
120
str
112
121
Random session name guaranteed to not collide with current ones.
122
+
123
+ Examples
124
+ --------
125
+ >>> get_test_session_name(server=server)
126
+ 'libtmux_...'
127
+
128
+ Never the same twice:
129
+ >>> get_test_session_name(server=server) != get_test_session_name(server=server)
130
+ True
113
131
"""
114
132
while True :
115
133
session_name = prefix + next (namer )
@@ -138,6 +156,15 @@ def get_test_window_name(
138
156
-------
139
157
str
140
158
Random window name guaranteed to not collide with current ones.
159
+
160
+ Examples
161
+ --------
162
+ >>> get_test_window_name(session=session)
163
+ 'libtmux_...'
164
+
165
+ Never the same twice:
166
+ >>> get_test_window_name(session=session) != get_test_window_name(session=session)
167
+ True
141
168
"""
142
169
assert prefix is not None
143
170
while True :
@@ -178,10 +205,9 @@ def temp_session(
178
205
179
206
Examples
180
207
--------
181
-
182
208
>>> with temp_session(server) as session:
183
209
... session.new_window(window_name='my window')
184
- Window(@... ...:... , Session($... ...))
210
+ Window(@3 2:my window , Session($... ...))
185
211
"""
186
212
187
213
if "session_name" in kwargs :
@@ -230,17 +256,15 @@ def temp_window(
230
256
231
257
Examples
232
258
--------
233
-
234
259
>>> with temp_window(session) as window:
235
260
... window
236
- Window(@... ... :..., Session($... ...))
261
+ Window(@2 2 :... Session($1 libtmux_ ...))
237
262
238
263
239
264
>>> with temp_window(session) as window:
240
265
... window.split_window()
241
- Pane(%... Window(@... ...: ..., Session($... ...)))
266
+ Pane(%4 Window(@3 2:libtmux_ ..., Session($1 libtmux_ ...)))
242
267
"""
243
-
244
268
if "window_name" not in kwargs :
245
269
window_name = get_test_window_name (session )
246
270
else :
@@ -262,21 +286,18 @@ def temp_window(
262
286
263
287
264
288
class EnvironmentVarGuard :
265
-
266
289
"""Mock environmental variables safetly.
267
290
268
291
Helps rotect the environment variable properly. Can be used as context
269
292
manager.
270
293
271
294
Notes
272
295
-----
273
-
274
296
Vendorized to fix issue with Anaconda Python 2 not including test module,
275
297
see #121 [1]_
276
298
277
299
References
278
300
----------
279
-
280
301
.. [1] Just installed, "ImportError: cannot import name test_support".
281
302
GitHub issue for tmuxp. https://github.com/tmux-python/tmuxp/issues/121.
282
303
Created October 12th, 2015. Accessed April 7th, 2018.
0 commit comments