mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Merge pull request #13 in TM/task from ~UNODE/task:2.4.0 to 2.4.0
* commit '22efbe3f74
':
Unittest - Testcase for bug TW-1381
Unittest - Testcase for bug TW-1379
No-color theme / Template theme
Unittest - Fix newlines should be interpreted in printed output
This commit is contained in:
commit
e070500d26
4 changed files with 213 additions and 0 deletions
45
doc/rc/no-color.theme
Normal file
45
doc/rc/no-color.theme
Normal file
|
@ -0,0 +1,45 @@
|
|||
# This is a theme that disables all default colors
|
||||
# It can be used as template for other themes
|
||||
|
||||
# If what you want is to disable all colors you can instead set "color=off"
|
||||
color.active=
|
||||
color.alternate=
|
||||
color.blocked=
|
||||
color.blocking=
|
||||
color.burndown.done=
|
||||
color.burndown.pending=
|
||||
color.burndown.started=
|
||||
color.calendar.due=
|
||||
color.calendar.due.today=
|
||||
color.calendar.holiday=
|
||||
color.calendar.overdue=
|
||||
color.calendar.today=
|
||||
color.calendar.weekend=
|
||||
color.calendar.weeknumber=
|
||||
color.debu=
|
||||
color.due=
|
||||
color.due.today=
|
||||
color.error=
|
||||
color.footnote=
|
||||
color.header=
|
||||
color.history.add=
|
||||
color.history.delete=
|
||||
color.history.done=
|
||||
color.overdue=
|
||||
color.pri.H=
|
||||
color.pri.L=
|
||||
color.pri.M=
|
||||
color.pri.none=
|
||||
color.project.none=
|
||||
color.recurring=
|
||||
color.scheduled=
|
||||
color.summary.background=
|
||||
color.summary.bar=
|
||||
color.sync.added=
|
||||
color.sync.changed=
|
||||
color.sync.rejected=
|
||||
color.tag.none=
|
||||
color.tagged=
|
||||
color.undo.after=
|
||||
color.undo.before=
|
||||
color.warning=
|
|
@ -66,6 +66,9 @@ class TAPTestResult(unittest.result.TestResult):
|
|||
def _do_stream(data, stream):
|
||||
"""Helper function for _mergeStdout"""
|
||||
for line in data.splitlines(True):
|
||||
# newlines should be taken literally and be comments in TAP
|
||||
line = line.replace("\\n", "\n# ")
|
||||
|
||||
# Add a comment sign before each line
|
||||
if line.startswith("#"):
|
||||
stream.write(line)
|
||||
|
|
136
test/tw-1379.t
Executable file
136
test/tw-1379.t
Executable file
|
@ -0,0 +1,136 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
REPO_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
class TestBug1379(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
# Themes are a special case that cannot be set via "task config"
|
||||
with open(self.t.taskrc, 'a') as fh:
|
||||
fh.write("include " + REPO_DIR + "/doc/rc/no-color.theme\n")
|
||||
|
||||
self.t.config("color.alternate", "")
|
||||
self.t.config("_forcecolor", "1")
|
||||
|
||||
# For use with regex
|
||||
self.RED = "\033\[31m"
|
||||
self.CLEAR = "\033\[0m"
|
||||
|
||||
def test_color_BLOCKED(self):
|
||||
"""color.tag.BLOCKED changes color of BLOCKED tasks"""
|
||||
self.t.config("color.tag.BLOCKED", "red")
|
||||
|
||||
self.t(("add", "Blocks"))
|
||||
self.t(("add", "dep:1", "Blocked"))
|
||||
|
||||
code, out, err = self.t(("all", "+BLOCKED"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Blocked.*" + self.CLEAR)
|
||||
|
||||
def test_color_UNBLOCKED(self):
|
||||
"""color.tag.UNBLOCKED changes color of UNBLOCKED tasks"""
|
||||
self.t.config("color.tag.UNBLOCKED", "red")
|
||||
|
||||
self.t(("add", "Blocks"))
|
||||
self.t(("add", "dep:1", "Blocked"))
|
||||
|
||||
code, out, err = self.t(("all", "+UNBLOCKED"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Blocks.*" + self.CLEAR)
|
||||
|
||||
def test_color_BLOCKING(self):
|
||||
"""color.tag.BLOCKING changes color of BLOCKING tasks"""
|
||||
self.t.config("color.tag.BLOCKING", "red")
|
||||
|
||||
self.t(("add", "Blocks"))
|
||||
self.t(("add", "dep:1", "Blocked"))
|
||||
|
||||
code, out, err = self.t(("all", "+BLOCKING"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Blocks.*" + self.CLEAR)
|
||||
|
||||
def test_color_SCHEDULED(self):
|
||||
"""color.tag.SCHEDULED changes color of SCHEDULED tasks"""
|
||||
self.t.config("color.tag.SCHEDULED", "red")
|
||||
|
||||
self.t(("add", "scheduled:tomorrow", "Have fun"))
|
||||
|
||||
code, out, err = self.t(("all", "+SCHEDULED"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Have fun.*" + self.CLEAR)
|
||||
|
||||
def test_color_UNTIL(self):
|
||||
"""color.tag.UNTIL changes color of UNTIL tasks"""
|
||||
self.t.config("color.tag.UNTIL", "red")
|
||||
|
||||
self.t(("add", "until:tomorrow", "Urgent"))
|
||||
|
||||
code, out, err = self.t(("all", "+UNTIL"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Urgent.*" + self.CLEAR)
|
||||
|
||||
def test_color_WAITING(self):
|
||||
"""color.tag.WAITING changes color of WAITING tasks"""
|
||||
self.t.config("color.tag.WAITING", "red")
|
||||
|
||||
self.t(("add", "wait:tomorrow", "Tomorrow"))
|
||||
|
||||
code, out, err = self.t(("all", "+WAITING"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Tomorrow.*" + self.CLEAR)
|
||||
|
||||
def test_color_PARENT(self):
|
||||
"""color.tag.PARENT changes color of PARENT tasks"""
|
||||
self.t.config("color.tag.PARENT", "red")
|
||||
|
||||
self.t(("add", "recur:daily", "due:tomorrow", "Email"))
|
||||
|
||||
code, out, err = self.t(("all", "+PARENT"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Email.*" + self.CLEAR)
|
||||
|
||||
def test_color_CHILD(self):
|
||||
"""color.tag.CHILD changes color of CHILD tasks"""
|
||||
self.t.config("color.tag.CHILD", "red")
|
||||
|
||||
self.t(("add", "recur:daily", "due:tomorrow", "Email"))
|
||||
|
||||
code, out, err = self.t(("all", "+CHILD"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Email.*" + self.CLEAR)
|
||||
|
||||
def test_color_PENDING(self):
|
||||
"""color.tag.PENDING changes color of PENDING tasks"""
|
||||
self.t.config("color.tag.PENDING", "red")
|
||||
|
||||
self.t(("add", "Pending"))
|
||||
|
||||
code, out, err = self.t(("all", "+PENDING"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Pending.*" + self.CLEAR)
|
||||
|
||||
def test_color_COMPLETED(self):
|
||||
"""color.tag.COMPLETED changes color of COMPLETED tasks"""
|
||||
self.t.config("color.tag.COMPLETED", "red")
|
||||
|
||||
self.t(("add", "Complete"))
|
||||
self.t(("1", "done"))
|
||||
|
||||
code, out, err = self.t(("all", "+COMPLETED"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Complete.*" + self.CLEAR)
|
||||
|
||||
def test_color_DELETED(self):
|
||||
"""color.tag.DELETED changes color of DELETED tasks"""
|
||||
self.t.config("color.tag.DELETED", "red")
|
||||
|
||||
self.t(("add", "Delete"))
|
||||
self.t(("1", "delete"))
|
||||
|
||||
code, out, err = self.t(("all", "+DELETED"))
|
||||
self.assertRegexpMatches(out, self.RED + r".*Delete.*" + self.CLEAR)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
29
test/tw-1381.t
Executable file
29
test/tw-1381.t
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
|
||||
class TestBug1381(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
def test_blocking(self):
|
||||
"""Blocking report displays tasks that are blocking other tasks"""
|
||||
self.t(("add", "blocks"))
|
||||
self.t(("add", "dep:1", "blocked"))
|
||||
code, out, err = self.t(("blocking",))
|
||||
|
||||
self.assertIn("blocks", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
Loading…
Add table
Add a link
Reference in a new issue