@@ -259,6 +259,7 @@ def test_window_options(session):
259259 w .select_layout (wconf ['layout' ])
260260
261261
262+ @pytest .mark .flaky (reruns = 5 )
262263def test_window_options_after (session ):
263264 yaml_config = loadfixture ("workspacebuilder/window_options_after.yaml" )
264265 s = session
@@ -270,21 +271,35 @@ def test_window_options_after(session):
270271 builder .build (session = session )
271272
272273 def assert_last_line (p , s ):
273- # Print output for easier debugging if test fails
274- print ('\n ' .join (p .cmd ('capture-pane' , '-p' ).stdout ))
275- assert p .cmd ('capture-pane' , '-p' ).stdout [- 2 ] == s
274+ correct = False
275+ for _ in range (10 ):
276+ pane_out = p .cmd ('capture-pane' , '-p' , '-J' ).stdout
277+ if len (pane_out ) > 1 and pane_out [- 2 ].strip () == s :
278+ correct = True
279+ break
280+
281+ time .sleep (0.1 )
282+
283+ # Print output for easier debugging if assertion fails
284+ if not correct :
285+ print ('\n ' .join (pane_out ))
286+
287+ return correct
276288
277289 for i , pane in enumerate (session .attached_window .panes ):
278- assert_last_line (pane , str (i ))
290+ assert assert_last_line (pane , str (i )), \
291+ "Initial command did not execute properly/" + str (i )
279292 pane .cmd ('send-keys' , 'Up' ) # Will repeat echo
280293 pane .enter () # in each iteration
281- assert_last_line (pane , str (i ))
294+ assert assert_last_line (pane , str (i )), \
295+ "Repeated command did not execute properly/" + str (i )
282296
283297 session .cmd ('send-keys' , ' echo moo' )
284298 session .cmd ('send-keys' , 'Enter' )
285299
286300 for pane in session .attached_window .panes :
287- assert_last_line (pane , 'moo' )
301+ assert assert_last_line (pane , 'moo' ), \
302+ "Synchronized command did not execute properly"
288303
289304
290305def test_window_shell (session ):
0 commit comments