@@ -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 :
@@ -233,12 +259,12 @@ def temp_window(
233
259
234
260
>>> with temp_window(session) as window:
235
261
... window
236
- Window(@... ... :..., Session($... ...))
262
+ Window(@2 2 :... Session($1 libtmux_ ...))
237
263
238
264
239
265
>>> with temp_window(session) as window:
240
266
... window.split_window()
241
- Pane(%... Window(@... ...: ..., Session($... ...)))
267
+ Pane(%4 Window(@3 2:libtmux_ ..., Session($1 libtmux_ ...)))
242
268
"""
243
269
244
270
if "window_name" not in kwargs :
@@ -262,21 +288,18 @@ def temp_window(
262
288
263
289
264
290
class EnvironmentVarGuard :
265
-
266
291
"""Mock environmental variables safetly.
267
292
268
293
Helps rotect the environment variable properly. Can be used as context
269
294
manager.
270
295
271
296
Notes
272
297
-----
273
-
274
298
Vendorized to fix issue with Anaconda Python 2 not including test module,
275
299
see #121 [1]_
276
300
277
301
References
278
302
----------
279
-
280
303
.. [1] Just installed, "ImportError: cannot import name test_support".
281
304
GitHub issue for tmuxp. https://github.com/tmux-python/tmuxp/issues/121.
282
305
Created October 12th, 2015. Accessed April 7th, 2018.
0 commit comments