From 22f7ea8348972a7d90e06cd378ffcd6f2647d059 Mon Sep 17 00:00:00 2001 From: Matt Behrens Date: Tue, 15 Aug 2017 22:35:57 +0200 Subject: [PATCH 1/4] Add session to all Session cmds, if it is not explicitly set --- libtmux/session.py | 9 +++++++-- tests/test_session.py | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libtmux/session.py b/libtmux/session.py index 5e141cf8f..c55d53f75 100644 --- a/libtmux/session.py +++ b/libtmux/session.py @@ -72,8 +72,13 @@ def cmd(self, *args, **kwargs): Renamed from ``.tmux`` to ``.cmd``. """ - if '-t' not in kwargs: - kwargs['-t'] = self.id + # if -t is not set in any arg yet + if not any('-t' in unicode(x) for x in args): + # insert -t immediately after 1st arg, as per tmux format + new_args = [args[0]] + new_args += ['-t', self.id] + new_args += args[1:] + args = new_args return self.server.cmd(*args, **kwargs) def attach_session(self): diff --git a/tests/test_session.py b/tests/test_session.py index 96460d1fa..26e775c3f 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -235,3 +235,11 @@ def test_periods_raise_badsessionname(server, session, session_name, raises): session.rename_session(new_name) with pytest.raises(exc.LibTmuxException): server.switch_client(new_name) + +def test_cmd_inserts_sesion_id(session): + current_session_id = session.id + last_arg = 'last-arg' + cmd = session.cmd('not-a-command', last_arg) + assert '-t' in cmd.cmd + assert current_session_id in cmd.cmd + assert cmd.cmd[-1] == last_arg From 47204ae133f2292fe948fcfb32adcc99c9cc0ee6 Mon Sep 17 00:00:00 2001 From: Matt Behrens Date: Wed, 16 Aug 2017 21:28:52 +0200 Subject: [PATCH 2/4] fix flake8 warning --- tests/test_session.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_session.py b/tests/test_session.py index 26e775c3f..c1e8dfcfb 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -236,6 +236,7 @@ def test_periods_raise_badsessionname(server, session, session_name, raises): with pytest.raises(exc.LibTmuxException): server.switch_client(new_name) + def test_cmd_inserts_sesion_id(session): current_session_id = session.id last_arg = 'last-arg' From 0562fe277436d3b2c8ec330966d6e4221d8e2e1f Mon Sep 17 00:00:00 2001 From: Matt Behrens Date: Wed, 16 Aug 2017 21:29:02 +0200 Subject: [PATCH 3/4] use py3 compat text type --- libtmux/session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libtmux/session.py b/libtmux/session.py index c55d53f75..ed5aab597 100644 --- a/libtmux/session.py +++ b/libtmux/session.py @@ -11,6 +11,7 @@ import os from . import exc, formats +from ._compat import text_type from .common import EnvironmentMixin, TmuxMappingObject, \ TmuxRelationalObject, session_check_name, handle_option_error from .window import Window @@ -73,7 +74,7 @@ def cmd(self, *args, **kwargs): """ # if -t is not set in any arg yet - if not any('-t' in unicode(x) for x in args): + if not any('-t' in text_type(x) for x in args): # insert -t immediately after 1st arg, as per tmux format new_args = [args[0]] new_args += ['-t', self.id] From a9bf0a550472fd48b5ef4b40c9f46e767c0a51b7 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Fri, 18 Aug 2017 05:51:39 -0500 Subject: [PATCH 4/4] allow failures with pypy3.3-5.2-alpha1 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9cf89caa6..f693fffe7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ env: - TMUX_VERSION=1.9a matrix: allow_failures: + - python: pypy3.3-5.2-alpha1 - env: TMUX_VERSION=master before_install: - export PIP_USE_MIRRORS=true