From dd0d4203f1c5dd42f638c2644ebf772d2f9b42ff Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 16 Dec 2016 04:00:55 +0100 Subject: [PATCH] python3: Make tests work --- tests/base.py | 16 +++++++++++++--- tests/test_selected.py | 8 ++++---- tests/test_splits.py | 32 ++++++++++++++++---------------- tests/test_viewport.py | 4 ++-- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/tests/base.py b/tests/base.py index 71577de..c77d75a 100644 --- a/tests/base.py +++ b/tests/base.py @@ -89,6 +89,16 @@ class IntegrationTest(object): sleep(0.5) # Killing takes some time self.tasks = self.__class__.tasks # Reset the task list + def py(self, command, silent=True, regex=None, lines=None, direct=False): + py_command = 'py ' if six.PY2 else 'py3 ' + + # Direct command communicate directly with the client + if direct: + return self.client.command(py_command + command) + else: + return self.command(py_command + command, + silent=silent, regex=regex, lines=lines) + def command(self, command, silent=True, regex=None, lines=None): result = self.client.command(command) @@ -140,9 +150,9 @@ class IntegrationTest(object): return False # Assert that TW and cache objects exist - cache_class = self.client.command('py print(cache.__class__.__name__)') - tw_class = self.client.command( - 'py print(cache.warriors["default"].__class__.__name__)') + cache_class = self.py('print(cache.__class__.__name__)', direct=True) + tw_class = self.py( + 'print(cache.warriors["default"].__class__.__name__)', direct=True) if not soft: assert tw_class == 'TaskWarrior' diff --git a/tests/test_selected.py b/tests/test_selected.py index 4d43cf8..728b316 100644 --- a/tests/test_selected.py +++ b/tests/test_selected.py @@ -247,7 +247,7 @@ class TestInfoAction(IntegrationTest): def execute(self): self.command("TaskWikiInfo") - assert self.command(":py print vim.current.buffer", silent=False).startswith("") sleep(0.5) - assert self.command(":py print vim.current.buffer", silent=False).startswith("') sleep(0.5) - assert self.command(":py print vim.current.buffer", regex="') sleep(0.5) - assert self.command(":py print vim.current.buffer", regex="