mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Unittest - Add mechanism to skip task and taskd tests
* When testing multiple clients vs server versions, repeating client tests is unnecessary. By setting the env variables TASKW_SKIP and TASKD_SKIP it will now be possible to skip all task (client only) and taskd (client + server) tests, respectively.
This commit is contained in:
parent
72e8a73ae0
commit
2a198d59fe
4 changed files with 25 additions and 5 deletions
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
from .task import Task
|
from .task import Task
|
||||||
from .taskd import Taskd
|
from .taskd import Taskd
|
||||||
from .testing import TestCase
|
from .testing import TestCase, ServerTestCase
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
|
from .utils import TASKW_SKIP, TASKD_SKIP
|
||||||
|
from .taskd import Taskd
|
||||||
|
|
||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class BaseTestCase(unittest.TestCase):
|
||||||
def diag(self, out):
|
def diag(self, out):
|
||||||
sys.stdout.write("# --- diag start ---\n")
|
sys.stdout.write("# --- diag start ---\n")
|
||||||
for line in out.split("\n"):
|
for line in out.split("\n"):
|
||||||
|
@ -12,4 +14,19 @@ class TestCase(unittest.TestCase):
|
||||||
sys.stdout.write("# --- diag end ---\n")
|
sys.stdout.write("# --- diag end ---\n")
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(TASKW_SKIP, "TASKW_SKIP set, skipping task tests.")
|
||||||
|
class TestCase(BaseTestCase):
|
||||||
|
"""Automatically skips tests if TASKW_SKIP is present in the environment
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(TASKD_SKIP, "TASKD_SKIP set, skipping taskd tests.")
|
||||||
|
@unittest.skipIf(Taskd.not_available(), "Taskd binary not available")
|
||||||
|
class ServerTestCase(BaseTestCase):
|
||||||
|
"""Automatically skips tests if TASKD_SKIP is present in the environment
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|
|
@ -13,6 +13,10 @@ from .exceptions import CommandError
|
||||||
USED_PORTS = set()
|
USED_PORTS = set()
|
||||||
ON_POSIX = 'posix' in sys.builtin_module_names
|
ON_POSIX = 'posix' in sys.builtin_module_names
|
||||||
|
|
||||||
|
# Environment flags to control skipping of task and taskd tests
|
||||||
|
TASKW_SKIP = os.environ.get("TASKW_SKIP", False)
|
||||||
|
TASKD_SKIP = os.environ.get("TASKD_SKIP", False)
|
||||||
|
|
||||||
|
|
||||||
def wait_process(proc, timeout=1):
|
def wait_process(proc, timeout=1):
|
||||||
"""Wait for process to finish
|
"""Wait for process to finish
|
||||||
|
|
|
@ -8,7 +8,7 @@ from datetime import datetime
|
||||||
# Ensure python finds the local simpletap module
|
# Ensure python finds the local simpletap module
|
||||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
from basetest import Task, Taskd, TestCase
|
from basetest import Task, TestCase, Taskd, ServerTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestBugNumber(TestCase):
|
class TestBugNumber(TestCase):
|
||||||
|
@ -53,8 +53,7 @@ class TestBugNumber(TestCase):
|
||||||
"""Executed once after all tests in the class"""
|
"""Executed once after all tests in the class"""
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(Taskd.not_available(), "Taskd binary not available")
|
class ServerTestBugNumber(ServerTestCase):
|
||||||
class ServerTestCase(TestCase):
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.taskd = Taskd()
|
cls.taskd = Taskd()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue