From: Rob Golding-Day Date: Mon, 13 May 2019 12:02:09 +0000 (+0100) Subject: Don't run `_get_version` when testing custom command X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/c7570e6e693efbb3485fbcd309f804b715c2de84?ds=sidebyside Don't run `_get_version` when testing custom command `wsl` doesn't exist on Travis CI! --- diff --git a/tasklib/backends.py b/tasklib/backends.py index fa4f766..38f6c59 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -95,7 +95,8 @@ class TaskWarrior(Backend): VERSION_2_4_5 = six.u('2.4.5') def __init__(self, data_location=None, create=True, - taskrc_location=None, task_command='task'): + taskrc_location=None, task_command='task', + version_override=None): self.taskrc_location = None if taskrc_location: self.taskrc_location = os.path.expanduser(taskrc_location) @@ -108,7 +109,7 @@ class TaskWarrior(Backend): self.task_command = task_command self._config = None - self.version = self._get_version() + self.version = version_override or self._get_version() self.overrides = { 'confirmation': 'no', 'dependency.confirmation': 'no', # See TW-1483 or taskrc man page diff --git a/tasklib/tests.py b/tasklib/tests.py index 6cba1fc..1fd449c 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -4,6 +4,7 @@ import copy import datetime import itertools import json +import os import pytz import six import shutil @@ -68,7 +69,11 @@ class TaskWarriorTest(TasklibTest): def test_custom_command(self): # ensure that a custom command which contains multiple parts # is properly split up - tw = self.get_taskwarrior(task_command='wsl task') + tw = self.get_taskwarrior( + task_command='wsl task', + # prevent `_get_version` from running as `wsl` may not exist + version_override=os.getenv('TASK_VERSION'), + ) self.assertEqual(tw._get_task_command(), ['wsl', 'task'])