Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert len(session.windows) == 1
assert len(session.attached_window().panes) == 1
current_windows = len(session._windows)
assert session.get('session_id') != '@0'
assert current_windows == 1
assert len(session.attached_window().panes) == 1
assert isinstance(session.server, Server)
# len(session.attached_window().panes))
assert len(session.windows), 1
assert len(session.attached_window().panes) == 1
for w in session.windows:
assert isinstance(w, Window)
window = session.attached_window()
assert isinstance(window, Window)
assert len(session.attached_window().panes) == 1
window.split_window()
session.attached_window().select_pane(pane_base_index)
session.attached_pane().send_keys('cd /srv/www/flaskr')
session.attached_window().select_pane(pane_base_index + 1)
session.attached_pane().send_keys('source .venv/bin/activate')
session.new_window(window_name='second')
current_windows += 1
assert current_windows == len(session._windows)
session.new_window(window_name='hey')
current_windows += 1
assert current_windows == len(session._windows)
session.select_window(1)
def test_select_window(session):
"""Session.select_window moves window."""
# get the current window_base_index, since different user tmux config
# may start at 0 or 1, or whatever they want.
window_base_index = int(session.attached_window.get('window_index'))
session.new_window(window_name='test_window')
window_count = len(session._windows)
assert window_count >= 2 # 2 or more windows
assert len(session._windows) == window_count
# tmux selects a window, moves to it, shows it as attached_window
selected_window1 = session.select_window(window_base_index)
assert isinstance(selected_window1, Window)
attached_window1 = session.attached_window
assert selected_window1 == attached_window1
assert selected_window1.__dict__ == attached_window1.__dict__
# again: tmux selects a window, moves to it, shows it as
# attached_window
selected_window2 = session.select_window(window_base_index + 1)
assert isinstance(selected_window2, Window)
attached_window2 = session.attached_window
assert selected_window2 == attached_window2
assert selected_window2.__dict__ == attached_window2.__dict__
# assure these windows were really different
assert selected_window1 != selected_window2
# get the current window_base_index, since different user tmux config
# may start at 0 or 1, or whatever they want.
window_base_index = int(
session.attached_window().get('window_index')
)
session.new_window(window_name='test_window')
window_count = len(session._windows)
assert window_count >= 2 # 2 or more windows
assert len(session._windows) == window_count
# tmux selects a window, moves to it, shows it as attached_window
selected_window1 = session.select_window(window_base_index)
assert isinstance(selected_window1, Window)
attached_window1 = session.attached_window()
assert selected_window1 == attached_window1
assert selected_window1.__dict__ == attached_window1.__dict__
# again: tmux selects a window, moves to it, shows it as
# attached_window
selected_window2 = session.select_window(window_base_index + 1)
assert isinstance(selected_window2, Window)
attached_window2 = session.attached_window()
assert selected_window2 == attached_window2
assert selected_window2.__dict__ == attached_window2.__dict__
# assure these windows were really different
assert selected_window1 != selected_window2
assert len(session.attached_window.panes) == 1
current_windows = len(session._windows)
assert session.get('session_id') != '@0'
assert current_windows == 1
assert len(session.attached_window.panes) == 1
assert isinstance(session.server, Server)
# len(session.attached_window.panes))
assert len(session.windows), 1
assert len(session.attached_window.panes) == 1
for w in session.windows:
assert isinstance(w, Window)
window = session.attached_window
assert isinstance(window, Window)
assert len(session.attached_window.panes) == 1
window.split_window()
session.attached_window.select_pane(pane_base_index)
session.attached_pane.send_keys('cd /srv/www/flaskr')
session.attached_window.select_pane(pane_base_index + 1)
session.attached_pane.send_keys('source .venv/bin/activate')
session.new_window(window_name='second')
current_windows += 1
assert current_windows == len(session._windows)
session.new_window(window_name='hey')
current_windows += 1
assert current_windows == len(session._windows)
session.select_window(1)
session.kill_window(target_window='hey')
current_windows -= 1
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
window_count = len(session._windows) # current window count
assert len(s._windows) == window_count
for w, wconf in builder.iter_create_windows(s):
for p in builder.iter_create_panes(w, wconf):
w.select_layout('tiled') # fix glitch with pane size
p = p
assert len(s._windows) == window_count
assert isinstance(w, Window)
assert len(s._windows) == window_count
window_count += 1
for w in session.windows:
pane_base_index = w.show_window_option('pane-base-index', g=True)
for p_index, p in enumerate(w.list_panes(), start=pane_base_index):
assert int(p_index) == int(p.index)
# pane-base-index start at base-index, pane_paths always start
# at 0 since python list.
pane_path = pane_paths[p_index - pane_base_index]
while retry():
p.server._update_panes()
if p.current_path == pane_path:
assert len(session.attached_window().panes) == 1
current_windows = len(session._windows)
assert session.get('session_id') != '@0'
assert current_windows == 1
assert len(session.attached_window().panes) == 1
assert isinstance(session.server, Server)
# len(session.attached_window().panes))
assert len(session.windows), 1
assert len(session.attached_window().panes) == 1
for w in session.windows:
assert isinstance(w, Window)
window = session.attached_window()
assert isinstance(window, Window)
assert len(session.attached_window().panes) == 1
window.split_window()
session.attached_window().select_pane(pane_base_index)
session.attached_pane().send_keys('cd /srv/www/flaskr')
session.attached_window().select_pane(pane_base_index + 1)
session.attached_pane().send_keys('source .venv/bin/activate')
session.new_window(window_name='second')
current_windows += 1
assert current_windows == len(session._windows)
session.new_window(window_name='hey')
current_windows += 1
assert current_windows == len(session._windows)
session.select_window(1)
session.kill_window(target_window='hey')
current_windows -= 1
for session in server.sessions:
session_id = session.get('session_id')
get_by_id = server.get_by_id(session_id)
assert get_by_id == session
assert isinstance(get_by_id, Session)
assert server.get_by_id('$' + next(namer)) is None
# session.get_by_id
for window in session.windows:
window_id = window.get('window_id')
get_by_id = session.get_by_id(window_id)
assert get_by_id == window
assert isinstance(get_by_id, Window)
assert session.get_by_id('@' + next(namer)) is None
# window.get_by_id
for pane in window.panes:
pane_id = pane.get('pane_id')
get_by_id = window.get_by_id(pane_id)
assert get_by_id == pane
assert isinstance(get_by_id, Pane)
assert window.get_by_id('%' + next(namer)) is None
def test_split_windows(session):
yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
s = session
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
builder = WorkspaceBuilder(sconf=sconfig)
window_count = len(session._windows) # current window count
assert len(s._windows) == window_count
for w, wconf in builder.iter_create_windows(s):
for p in builder.iter_create_panes(w, wconf):
w.select_layout('tiled') # fix glitch with pane size
p = p
assert len(s._windows) == window_count
assert isinstance(w, Window)
assert len(s._windows) == window_count
window_count += 1
for session in server.sessions:
session_id = session.get('session_id')
get_by_id = server.getById(session_id)
assert get_by_id == session
assert isinstance(get_by_id, Session)
assert server.getById('$' + next(namer)) is None
# session.getById
for window in session.windows:
window_id = window.get('window_id')
get_by_id = session.getById(window_id)
assert get_by_id == window
assert isinstance(get_by_id, Window)
assert session.getById('@' + next(namer)) is None
# window.getById
for pane in window.panes:
pane_id = pane.get('pane_id')
get_by_id = window.getById(pane_id)
assert get_by_id == pane
assert isinstance(get_by_id, Pane)
assert window.getById('%' + next(namer)) is None
assert len(session.windows) == 1
assert len(session.attached_window.panes) == 1
current_windows = len(session._windows)
assert session.get('session_id') != '@0'
assert current_windows == 1
assert len(session.attached_window.panes) == 1
assert isinstance(session.server, Server)
# len(session.attached_window.panes))
assert len(session.windows), 1
assert len(session.attached_window.panes) == 1
for w in session.windows:
assert isinstance(w, Window)
window = session.attached_window
assert isinstance(window, Window)
assert len(session.attached_window.panes) == 1
window.split_window()
session.attached_window.select_pane(pane_base_index)
session.attached_pane.send_keys('cd /srv/www/flaskr')
session.attached_window.select_pane(pane_base_index + 1)
session.attached_pane.send_keys('source .venv/bin/activate')
session.new_window(window_name='second')
current_windows += 1
assert current_windows == len(session._windows)
session.new_window(window_name='hey')
current_windows += 1
assert current_windows == len(session._windows)
session.select_window(1)