From 4434f1527b48c2fda90d0999c3942e35ec3c9af5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 07:56:30 -0500 Subject: [PATCH 1/6] Update find_where, attached_{sessions,windows,..} --- tests/test_workspacebuilder.py | 30 +++++++++++++++--------------- tmuxp/cli.py | 2 +- tmuxp/workspacebuilder.py | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/test_workspacebuilder.py b/tests/test_workspacebuilder.py index b01c325e11..bf62e543c6 100644 --- a/tests/test_workspacebuilder.py +++ b/tests/test_workspacebuilder.py @@ -80,11 +80,11 @@ def test_focus_pane_index(session): builder.build(session=session) - assert session.attached_window().get('window_name') == \ + assert session.attached_window.get('window_name') == \ 'focused window' pane_base_index = int( - session.attached_window().show_window_option( + session.attached_window.show_window_option( 'pane-base-index', g=True ) ) @@ -96,19 +96,19 @@ def test_focus_pane_index(session): # get the pane index for each pane pane_base_indexes = [] - for pane in session.attached_window().panes: + for pane in session.attached_window.panes: pane_base_indexes.append(int(pane.get('pane_index'))) pane_indexes_should_be = [pane_base_index + x for x in range(0, 3)] assert pane_indexes_should_be == pane_base_indexes - w = session.attached_window() + w = session.attached_window assert w.get('window_name') != 'man' pane_path = '/usr' for i in range(20): - p = w.attached_pane() + p = w.attached_pane p.server._update_panes() if p.get('pane_current_path') == pane_path: break @@ -120,13 +120,13 @@ def test_focus_pane_index(session): base_index = int(proc.stdout[0]) session.server._update_windows() - window3 = session.findWhere({'window_index': str(base_index + 2)}) + window3 = session.find_where({'window_index': str(base_index + 2)}) assert isinstance(window3, Window) p = None pane_path = '/' for i in range(10): - p = window3.attached_pane() + p = window3.attached_pane p.server._update_panes() if p.get('pane_current_path') == pane_path: break @@ -146,10 +146,10 @@ def test_suppress_history(session): builder = WorkspaceBuilder(sconf=sconfig) builder.build(session=session) - inHistoryPane = session.findWhere( - {'window_name': 'inHistory'}).attached_pane() - isMissingPane = session.findWhere( - {'window_name': 'isMissing'}).attached_pane() + inHistoryPane = session.find_where( + {'window_name': 'inHistory'}).attached_pane + isMissingPane = session.find_where( + {'window_name': 'isMissing'}).attached_pane def assertHistory(cmd, hist): return 'inHistory' in cmd and cmd == hist @@ -309,18 +309,18 @@ def test_blank_pane_count(session): assert session == builder.session - window1 = session.findWhere({'window_name': 'Blank pane test'}) + window1 = session.find_where({'window_name': 'Blank pane test'}) assert len(window1._panes) == 3 - window2 = session.findWhere({'window_name': 'More blank panes'}) + window2 = session.find_where({'window_name': 'More blank panes'}) assert len(window2._panes) == 3 - window3 = session.findWhere( + window3 = session.find_where( {'window_name': 'Empty string (return)'} ) assert len(window3._panes) == 3 - window4 = session.findWhere({'window_name': 'Blank with options'}) + window4 = session.find_where({'window_name': 'Blank with options'}) assert len(window4._panes) == 2 diff --git a/tmuxp/cli.py b/tmuxp/cli.py index 783db48ad3..f220f930c1 100644 --- a/tmuxp/cli.py +++ b/tmuxp/cli.py @@ -329,7 +329,7 @@ def command_freeze(args): ) try: - session = t.findWhere({ + session = t.find_where({ 'session_name': ctext }) diff --git a/tmuxp/workspacebuilder.py b/tmuxp/workspacebuilder.py index ae2900c81d..464f17c655 100644 --- a/tmuxp/workspacebuilder.py +++ b/tmuxp/workspacebuilder.py @@ -115,7 +115,7 @@ def build(self, session=None): ) if self.server.has_session(self.sconf['session_name']): - self.session = self.server.findWhere( + self.session = self.server.find_where( { 'session_name': self.sconf['session_name'] } @@ -196,7 +196,7 @@ def iter_create_windows(self, s): w1 = None if i == int(1): # if first window, use window 1 - w1 = s.attached_window() + w1 = s.attached_window w1.move_window(99) pass @@ -252,7 +252,7 @@ def iter_create_panes(self, w, wconf): for pindex, pconf in enumerate(wconf['panes'], start=pane_base_index): if pindex == int(pane_base_index): - p = w.attached_pane() + p = w.attached_pane else: def get_pane_start_directory(): From 2269b7f335b50ed456287128f853efe122a0ff58 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 10:53:36 -0500 Subject: [PATCH 2/6] switch to using attributes from libtmux --- tests/test_workspacebuilder.py | 44 +++++++++++++++++----------------- tmuxp/workspacebuilder.py | 22 ++++++++--------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/test_workspacebuilder.py b/tests/test_workspacebuilder.py index bf62e543c6..13aeab53ee 100644 --- a/tests/test_workspacebuilder.py +++ b/tests/test_workspacebuilder.py @@ -80,7 +80,7 @@ def test_focus_pane_index(session): builder.build(session=session) - assert session.attached_window.get('window_name') == \ + assert session.attached_window.name == \ 'focused window' pane_base_index = int( @@ -97,24 +97,24 @@ def test_focus_pane_index(session): # get the pane index for each pane pane_base_indexes = [] for pane in session.attached_window.panes: - pane_base_indexes.append(int(pane.get('pane_index'))) + pane_base_indexes.append(int(pane.index)) pane_indexes_should_be = [pane_base_index + x for x in range(0, 3)] assert pane_indexes_should_be == pane_base_indexes w = session.attached_window - assert w.get('window_name') != 'man' + assert w.name != 'man' pane_path = '/usr' for i in range(20): p = w.attached_pane p.server._update_panes() - if p.get('pane_current_path') == pane_path: + if p.current_path == pane_path: break time.sleep(.4) - assert p.get('pane_current_path') == pane_path + assert p.current_path == pane_path proc = session.cmd('show-option', '-gv', 'base-index') base_index = int(proc.stdout[0]) @@ -128,11 +128,11 @@ def test_focus_pane_index(session): for i in range(10): p = window3.attached_pane p.server._update_panes() - if p.get('pane_current_path') == pane_path: + if p.current_path == pane_path: break time.sleep(.4) - assert p.get('pane_current_path') == pane_path + assert p.current_path == pane_path @flaky(max_runs=5, min_passes=1) @@ -227,7 +227,7 @@ def test_window_shell(session): break time.sleep(.2) - assert w.get('window_name') != text_type('top') + assert w.name != text_type('top') def test_environment_variables(session): @@ -266,27 +266,27 @@ def test_automatic_rename_option(session): window_count += 1 w.select_layout(wconf['layout']) - assert s.get('session_name') != 'tmuxp' + assert s.name != 'tmuxp' w = s.windows[0] for i in range(10): session.server._update_windows() - if w.get('window_name') != 'sh': + if w.name != 'sh': break time.sleep(.2) - assert w.get('window_name') != 'sh' + assert w.name != 'sh' pane_base_index = w.show_window_option('pane-base-index', g=True) w.select_pane(pane_base_index) for i in range(10): session.server._update_windows() - if w.get('window_name') == 'sh': + if w.name == 'sh': break time.sleep(.3) - assert w.get('window_name') == text_type('sh') + assert w.name == text_type('sh') w.select_pane('-D') for i in range(10): @@ -295,7 +295,7 @@ def test_automatic_rename_option(session): break time.sleep(.2) - assert w.get('window_name') != text_type('sh') + assert w.name != text_type('sh') def test_blank_pane_count(session): @@ -352,7 +352,7 @@ def test_start_directory(session, tmpdir): for p in window.panes: for i in range(60): p.server._update_panes() - pane_path = p.get('pane_current_path') + pane_path = p.current_path if pane_path is None: pass elif ( @@ -419,7 +419,7 @@ def test_start_directory_relative(session, tmpdir): for i in range(60): p.server._update_panes() # Handle case where directories resolve to /private/ in OSX - pane_path = p.get('pane_current_path') + pane_path = p.current_path if pane_path is None: pass elif ( @@ -479,7 +479,7 @@ def test_pane_order(session): 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.get('pane_index')) + assert int(p_index) == int(p.index) # pane-base-index start at base-index, pane_paths always start # at 0 since python list. @@ -487,11 +487,11 @@ def test_pane_order(session): for i in range(60): p.server._update_panes() - if p.get('pane_current_path') == pane_path: + if p.current_path == pane_path: break time.sleep(.2) - assert p.get('pane_current_path'), pane_path + assert p.current_path, pane_path def test_window_index(session): @@ -533,7 +533,7 @@ def test_before_load_throw_error_if_retcode_error(server): builder = WorkspaceBuilder(sconf=sconfig) with temp_session(server) as sess: - session_name = sess.get('session_name') + session_name = sess.name with pytest.raises(exc.BeforeLoadScriptError): builder.build(session=sess) @@ -561,9 +561,9 @@ def test_before_load_throw_error_if_file_not_exists(server): builder = WorkspaceBuilder(sconf=sconfig) with temp_session(server) as sess: - session_name = sess.get('session_name') + session_name = sess.name temp_session_exists = server.has_session( - sess.get('session_name') + sess.name ) assert temp_session_exists with pytest.raises( diff --git a/tmuxp/workspacebuilder.py b/tmuxp/workspacebuilder.py index 464f17c655..2e27a23f21 100644 --- a/tmuxp/workspacebuilder.py +++ b/tmuxp/workspacebuilder.py @@ -129,15 +129,15 @@ def build(self, session=None): session_name=self.sconf['session_name'] ) - assert(self.sconf['session_name'] == session.get('session_name')) + assert(self.sconf['session_name'] == session.name) assert(len(self.sconf['session_name']) > 0) self.session = session self.server = session.server self.server._list_sessions() - assert self.server.has_session(session.get('session_name')) - assert session.get('session_id') + assert self.server.has_session(session.name) + assert session.id assert(isinstance(session, Session)) @@ -269,7 +269,7 @@ def get_pane_start_directory(): ) assert(isinstance(p, Pane)) - assert(int(p.get('pane_index')) == int(pindex)) + assert(int(p.index) == int(pindex)) if 'layout' in wconf: w.select_layout(wconf['layout']) @@ -304,8 +304,8 @@ def freeze(session): for w in session.windows: wconf = { 'options': w.show_window_options(), - 'window_name': w.get('window_name'), - 'layout': w.get('window_layout'), + 'window_name': w.name, + 'layout': w.layout, 'panes': [] } if w.get('window_active', '0') == '1': @@ -315,25 +315,25 @@ def freeze(session): # of using 'cd' shell commands. def pane_has_same_path(p): return ( - w.panes[0].get('pane_current_path') == - p.get('pane_current_path') + w.panes[0].current_path == + p.current_path ) if all(pane_has_same_path(p) for p in w.panes): - wconf['start_directory'] = w.panes[0].get('pane_current_path') + wconf['start_directory'] = w.panes[0].current_path for p in w.panes: pconf = {'shell_command': []} if 'start_directory' not in wconf: pconf['shell_command'].append( - 'cd ' + p.get('pane_current_path') + 'cd ' + p.current_path ) if p.get('pane_active', '0') == '1': pconf['focus'] = 'true' - current_cmd = p.get('pane_current_command') + current_cmd = p.current_command def filter_interpretters_and_shells(): return ( From f1f3916d6659aff4d0ac8cbc03abea9b154850f1 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 11:08:20 -0500 Subject: [PATCH 3/6] Remove unused links from README --- README.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.rst b/README.rst index dbef21fa19..2415f9d862 100644 --- a/README.rst +++ b/README.rst @@ -130,9 +130,6 @@ tests .. code-block:: bash .. _BSD: http://opensource.org/licenses/BSD-3-Clause .. _developing and testing: http://tmuxp.readthedocs.io/en/latest/developing.html -.. _installing bash completion: http://tmuxp.readthedocs.io/en/latest/quickstart.html#bash-completion -.. _Developing and Testing: http://tmuxp.readthedocs.io/en/latest/developing.html -.. _Issues tracker: https://github.com/tony/tmuxp/issues .. |pypi| image:: https://img.shields.io/pypi/v/tmuxp.svg :alt: Python Package From 75fe26d90a9fbb87d8bf0a39eae4ce2b398ffd97 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 12:07:51 -0500 Subject: [PATCH 4/6] update libtmux to 0.4 --- requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/base.txt b/requirements/base.txt index a893bd008a..22ee38c1e0 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,4 +1,4 @@ kaptan>=0.5.7 -libtmux==0.3 +libtmux==0.4 argcomplete colorama From 33900954a768e8062900a9da95bac52940bbcbb9 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 12:42:19 -0500 Subject: [PATCH 5/6] Remove unused loggers in tests --- tests/test_cli.py | 3 --- tests/test_config.py | 2 -- tests/test_config_teamocil.py | 2 -- tests/test_config_tmuxinator.py | 2 -- tests/test_util.py | 3 --- tests/test_workspacebuilder.py | 3 --- tests/test_workspacefreezer.py | 3 --- 7 files changed, 18 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 59c5619065..97b748c188 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4,13 +4,10 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os from tmuxp import cli, config -logger = logging.getLogger(__name__) - def test_creates_config_dir_not_exists(tmpdir): """cli.startup() creates config dir if not exists.""" diff --git a/tests/test_config.py b/tests/test_config.py index 6b38ceecbd..d0ddc77971 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os import kaptan @@ -16,7 +15,6 @@ from . import example_dir from .fixtures import config as fixtures -logger = logging.getLogger(__name__) TMUXP_DIR = os.path.join(os.path.dirname(__file__), '.tmuxp') diff --git a/tests/test_config_teamocil.py b/tests/test_config_teamocil.py index af83fa2ab8..0cfddd5546 100644 --- a/tests/test_config_teamocil.py +++ b/tests/test_config_teamocil.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os import kaptan @@ -14,7 +13,6 @@ from .fixtures import config_teamocil as fixtures -logger = logging.getLogger(__name__) TMUXP_DIR = os.path.join(os.path.dirname(__file__), '.tmuxp') diff --git a/tests/test_config_tmuxinator.py b/tests/test_config_tmuxinator.py index 3e35b7756c..640946cd89 100644 --- a/tests/test_config_tmuxinator.py +++ b/tests/test_config_tmuxinator.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os import kaptan @@ -14,7 +13,6 @@ from .fixtures import config_tmuxinator as fixtures -logger = logging.getLogger(__name__) TMUXP_DIR = os.path.join(os.path.dirname(__file__), '.tmuxp') diff --git a/tests/test_util.py b/tests/test_util.py index f4b69a7699..407615890c 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os import pytest @@ -15,8 +14,6 @@ from . import fixtures_dir -logger = logging.getLogger(__name__) - def test_raise_BeforeLoadScriptNotExists_if_not_exists(): script_file = os.path.join(fixtures_dir, 'script_noexists.sh') diff --git a/tests/test_workspacebuilder.py b/tests/test_workspacebuilder.py index 13aeab53ee..2c38ac30d3 100644 --- a/tests/test_workspacebuilder.py +++ b/tests/test_workspacebuilder.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import os import time @@ -22,8 +21,6 @@ from . import example_dir from .fixtures._util import loadfixture -logger = logging.getLogger(__name__) - def test_split_windows(session): yaml_config = loadfixture("workspacebuilder/two_pane.yaml") diff --git a/tests/test_workspacefreezer.py b/tests/test_workspacefreezer.py index e3953153cc..c40c456771 100644 --- a/tests/test_workspacefreezer.py +++ b/tests/test_workspacefreezer.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals, with_statement) -import logging import time import kaptan @@ -14,8 +13,6 @@ from .fixtures._util import loadfixture -logger = logging.getLogger(__name__) - def test_freeze_config(session): yaml_config = loadfixture("workspacefreezer/sampleconfig.yaml") From ba99c54ea34d9e864bb2820795e764c18048f031 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 28 May 2016 13:58:31 -0500 Subject: [PATCH 6/6] bump to libtmux 0.4.1 --- requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/base.txt b/requirements/base.txt index 22ee38c1e0..b2f72bc09d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,4 +1,4 @@ kaptan>=0.5.7 -libtmux==0.4 +libtmux==0.4.1 argcomplete colorama