Skip to content

Commit 0ab3695

Browse files
committed
Update test for suppress_history
1 parent 44d37d2 commit 0ab3695

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

tmuxp/testsuite/workspacebuilder.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,27 @@ def test_suppress_history(self):
238238

239239
builder = WorkspaceBuilder(sconf=sconfig)
240240
builder.build(session=self.session)
241-
time.sleep(0.3) # give .bashrc, etc. time to load
242241

243-
s.server._update_windows()
244-
for w in s.windows:
245-
w.server._update_panes()
246-
w.select_window()
247-
for p in w.panes:
248-
p.select_pane()
242+
inHistoryPane = self.session.findWhere(
243+
{'window_name': 'inHistory'}).attached_pane()
244+
isMissingPane = self.session.findWhere(
245+
{'window_name': 'isMissing'}).attached_pane()
246+
assertHistory = lambda cmd, hist: 'inHistory' in cmd and cmd == hist
247+
assertIsMissing = lambda cmd, hist: 'isMissing' in cmd and cmd != hist
249248

250-
# Print the last-in-history command in the pane
251-
self.session.cmd('send-keys', ' fc -ln -1')
252-
self.session.cmd('send-keys', 'Enter')
253-
time.sleep(0.1) # give fc time to run
249+
for p, assertCase in [
250+
(inHistoryPane, assertHistory,), (isMissingPane, assertIsMissing,)
251+
]:
252+
correct = False
253+
p.window.select_window()
254+
p.select_pane()
255+
256+
# Print the last-in-history command in the pane
257+
self.session.cmd('send-keys', ' fc -ln -1')
258+
self.session.cmd('send-keys', 'Enter')
259+
260+
for i in range(10):
261+
time.sleep(0.1)
254262

255263
# Get the contents of the pane
256264
self.session.cmd('capture-pane')
@@ -261,15 +269,10 @@ def test_suppress_history(self):
261269
sent_cmd = captured_pane.stdout[0].strip()
262270
history_cmd = captured_pane.stdout[-2].strip()
263271

264-
# If it was in the history, sent == history
265-
if 'inHistory' in sent_cmd:
266-
self.assertEqual(sent_cmd, history_cmd)
267-
# Otherwise, sent != history
268-
elif 'isMissing' in sent_cmd:
269-
self.assertNotEqual(sent_cmd, history_cmd)
270-
# Something went wrong
271-
else:
272-
self.fail("Unknown sent command: [%s]" % sent_cmd)
272+
if assertCase(sent_cmd, history_cmd):
273+
correct = True
274+
break
275+
self.assertTrue(correct, "Unknown sent command: [%s]" % sent_cmd)
273276

274277

275278
class WindowOptions(TmuxTestCase):

0 commit comments

Comments
 (0)