|
5 | 5 | unicode_literals, with_statement)
|
6 | 6 |
|
7 | 7 | import os
|
8 |
| -import time |
9 | 8 |
|
10 | 9 | import kaptan
|
11 | 10 | import pytest
|
12 | 11 | from libtmux import Window
|
13 | 12 | from libtmux.common import has_gte_version
|
14 |
| -from libtmux.test import temp_session |
| 13 | +from libtmux.test import temp_session, retry |
15 | 14 |
|
16 | 15 | from tmuxp import config, exc
|
17 | 16 | from tmuxp._compat import text_type
|
|
20 | 19 | from . import example_dir, fixtures_dir
|
21 | 20 | from .fixtures._util import loadfixture
|
22 | 21 |
|
23 |
| -RETRY_TIMEOUT_SECONDS = int(os.getenv('RETRY_TIMEOUT_SECONDS', 8)) |
24 |
| - |
25 |
| - |
26 |
| -def retry(seconds=RETRY_TIMEOUT_SECONDS): |
27 |
| - """Retry a block of code until a time limit or ``break``. |
28 |
| -
|
29 |
| - .. code-block:: python |
30 |
| -
|
31 |
| - while retry(): |
32 |
| - p = w.attached_pane |
33 |
| - p.server._update_panes() |
34 |
| - if p.current_path == pane_path: |
35 |
| - break |
36 |
| -
|
37 |
| -
|
38 |
| - :param seconds: Seconds to retry, defaults to ``RETRY_TIMEOUT_SECONDS``, |
39 |
| - which is configurable via environmental variables. |
40 |
| - :type seconds: int |
41 |
| - :rtype: void |
42 |
| -
|
43 |
| - :todo: Move to libtmux.test |
44 |
| - """ |
45 |
| - return (lambda: time.time() < time.time() + seconds)() |
46 |
| - |
47 | 22 |
|
48 | 23 | def test_split_windows(session):
|
49 | 24 | yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
|
@@ -199,8 +174,7 @@ def assertIsMissing(cmd, hist):
|
199 | 174 | p.cmd('send-keys', 'Enter')
|
200 | 175 |
|
201 | 176 | buffer_name = 'test'
|
202 |
| - for _ in range(10): |
203 |
| - time.sleep(0.1) |
| 177 | + while retry(): |
204 | 178 | # from v0.7.4 libtmux session.cmd adds target -t self.id by default
|
205 | 179 | # show-buffer doesn't accept -t, use global cmd.
|
206 | 180 |
|
|
0 commit comments