22from __future__ import absolute_import , division , print_function , with_statement
33
44import os
5+ import sys
56import logging
67import time
78import kaptan
8- from .. import Window , config , exc
9+ from .. import Window , config , exc , util
910from ..workspacebuilder import WorkspaceBuilder
1011from .helpers import TmuxTestCase
1112
@@ -132,7 +133,6 @@ def test_split_windows(self):
132133 s = self .session
133134 sconfig = kaptan .Kaptan (handler = 'yaml' )
134135 sconfig = sconfig .import_config (self .yaml_config ).get ()
135- import sys
136136
137137 builder = WorkspaceBuilder (sconf = sconfig )
138138
@@ -247,24 +247,34 @@ def test_automatic_rename_option(self):
247247 window_count += 1
248248 w .select_layout (wconf ['layout' ])
249249
250- w = s .attached_window ()
250+ self .assertNotEqual (s .get ('session_name' ), 'tmuxp' )
251+ w = s .windows [0 ]
251252
252253 for i in range (30 ):
253- w = s .attached_window ()
254- if w ['window_name' ] == 'man' :
254+ if w .get ('window_name' ) != 'man' :
255255 break
256256 time .sleep (.2 )
257257
258- self .assertEqual (w .get ('window_name' ), 'man' )
258+ self .assertNotEqual (w .get ('window_name' ), 'man' )
259+
260+ pane_base_index = w .show_window_option ('pane-base-index' , g = True )
261+ w .select_pane (pane_base_index )
262+
263+ for i in range (30 ):
264+ self .session .server ._update_windows ()
265+ if w .get ('window_name' ) == 'man' :
266+ break
267+ time .sleep (.2 )
268+
269+ self .assertEqual (w .get ('window_name' ), unicode ('man' ))
259270
260271 w .select_pane ('-D' )
261272 for i in range (30 ):
262- w = s .attached_window ()
263273 if w ['window_name' ] != 'man' :
264274 break
265275 time .sleep (.2 )
266276
267- self .assertNotEqual (w .get ('window_name' ), 'man' )
277+ self .assertEqual (w .get ('window_name' ), unicode ( 'man' ) )
268278
269279
270280class BlankPaneTest (TmuxTestCase ):
@@ -342,8 +352,6 @@ def test_start_directory(self):
342352 sconfig = config .expand (sconfig )
343353 sconfig = config .trickle (sconfig )
344354
345- logger .error (sconfig )
346-
347355 builder = WorkspaceBuilder (sconf = sconfig )
348356 builder .build (session = self .session )
349357
@@ -376,6 +384,14 @@ class PaneOrderingTest(TmuxTestCase):
376384 """
377385
378386 def test_pane_order (self ):
387+
388+ # test order of `panes` (and pane_index) above aganist pane_dirs
389+ pane_paths = [
390+ '/var/log' ,
391+ '/sys' ,
392+ '/sbin' ,
393+ '/tmp'
394+ ]
379395 s = self .session
380396 sconfig = kaptan .Kaptan (handler = 'yaml' )
381397 sconfig = sconfig .import_config (self .yaml_config ).get ()
@@ -399,11 +415,19 @@ def test_pane_order(self):
399415
400416 for w in self .session .windows :
401417 import time
402- time .sleep (.5 )
403- for p_index , p in enumerate (w .list_panes (), start = w .show_window_option ('pane-base-index' , g = True )):
404- #for p in w.list_panes():
405- logger .error (p .get ('pane_current_path' ))
418+ time .sleep (1 )
419+ pane_base_index = w .show_window_option ('pane-base-index' , g = True )
420+ for p_index , p in enumerate (w .list_panes (), start = pane_base_index ):
406421 self .assertEqual (int (p_index ), int (p .get ('pane_index' )))
407- logger .error ('pane-base-index: %s, p_index: %s, pane_index: %s' % (
408- w .show_window_option ('pane-base-index' , g = True ), p_index , p .get ('pane_index' )
409- ))
422+
423+ # pane-base-index start at base-index, pane_paths always start
424+ # at 0 since python list.
425+ pane_path = pane_paths [p_index - pane_base_index ]
426+
427+ for i in range (30 ):
428+ p .server ._update_panes ()
429+ if p .get ('pane_current_path' ) == pane_path :
430+ break
431+ time .sleep (.2 )
432+
433+ self .assertEqual (p .get ('pane_current_path' ), pane_path )
0 commit comments