File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -278,19 +278,22 @@ def kill_window(self):
278278
279279 self .server ._update_windows ()
280280
281- def move_window (self , destination ):
281+ def move_window (self , destination = "" , session = None ):
282282 """Move the current :class:`Window` object ``$ tmux move-window``.
283283
284284 :param destination: the ``target window`` or index to move the window
285- to.
286- :type target_window: string
285+ to, default: empty string
286+ :type destination: string
287+ :param session: the ``target session`` or index to move the
288+ window to, default: current session.
289+ :type session: string
287290
288291 """
289-
292+ session = session or self . get ( 'session_id' )
290293 proc = self .cmd (
291294 'move-window' ,
292295 '-s%s:%s' % (self .get ('session_id' ), self .index ),
293- '-t%s:%s' % (self . get ( 'session_id' ) , destination ),
296+ '-t%s:%s' % (session , destination ),
294297 )
295298
296299 if proc .stderr :
Original file line number Diff line number Diff line change @@ -81,3 +81,10 @@ def test_set_show_environment_single(server, session):
8181def test_show_environment_not_set (server ):
8282 """Unset environment variable returns None."""
8383 assert server .show_environment ('BAR' ) is None
84+
85+
86+ def test_new_session (server ):
87+ """Server.new_session creates and returns valid session"""
88+ mysession = server .new_session ("test_new_session" )
89+ assert mysession .get ("session_name" ) == "test_new_session"
90+ assert server .has_session ("test_new_session" )
Original file line number Diff line number Diff line change @@ -200,3 +200,19 @@ def test_set_window_option_bad(session):
200200
201201 with pytest .raises (exc .UnknownOption ):
202202 window .set_window_option ('afewewfew' , 43 )
203+
204+
205+ def test_move_window (session ):
206+ """Window.move_window results in changed index"""
207+
208+ window = session .new_window (window_name = 'test_window' )
209+ new_index = str (int (window .index ) + 1 )
210+ window .move_window (new_index )
211+ assert window .index == new_index
212+
213+
214+ def test_move_window_to_other_session (server , session ):
215+ window = session .new_window (window_name = 'test_window' )
216+ new_session = server .new_session ("test_move_window" )
217+ window .move_window (session = new_session .get ('session_id' ))
218+ assert new_session .get_by_id (window .get ("window_id" )) == window
You can’t perform that action at this time.
0 commit comments