Skip to content

Commit 23face2

Browse files
committed
tests(automatic_rename_option): Use retry_until()
1 parent 709dc43 commit 23face2

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

tests/test_workspacebuilder.py

+8-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import libtmux
1212
from libtmux import Window
1313
from libtmux.common import has_gte_version
14-
from libtmux.test import retry, temp_session
14+
from libtmux.test import retry, retry_until, temp_session
1515
from tmuxp import config, exc
1616
from tmuxp.cli.load import load_plugins
1717
from tmuxp.workspacebuilder import WorkspaceBuilder
@@ -386,36 +386,24 @@ def test_automatic_rename_option(session):
386386
assert s.name != "tmuxp"
387387
w = s.windows[0]
388388

389-
t = time.process_time()
390-
while (time.process_time() - t) * 1000 < 20:
389+
def check_window_name_mismatch() -> bool:
391390
session.server._update_windows()
392-
if w.name != portable_command:
393-
break
394-
time.sleep(0.2)
391+
return w.name != portable_command
395392

396-
assert w.name != portable_command
393+
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
397394

398395
pane_base_index = w.show_window_option("pane-base-index", g=True)
399396
w.select_pane(pane_base_index)
400397

401-
t = time.process_time()
402-
while (time.process_time() - t) * 1000 < 20:
398+
def check_window_name_match() -> bool:
403399
session.server._update_windows()
404-
if w.name == portable_command:
405-
break
406-
time.sleep(0.2)
400+
return w.name == portable_command
407401

408-
assert w.name == portable_command
402+
assert retry_until(check_window_name_match, 2, interval=0.25)
409403

410404
w.select_pane("-D")
411405

412-
t = time.process_time()
413-
while (time.process_time() - t) * 1000 < 20:
414-
session.server._update_windows()
415-
if w["window_name"] != portable_command:
416-
break
417-
time.sleep(0.2)
418-
assert w.name != portable_command
406+
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
419407

420408

421409
def test_blank_pane_count(session):

0 commit comments

Comments
 (0)