From f39617a75338fc3a200cff636f851928eefb00fc Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Thu, 24 Jul 2014 13:07:39 +0100 Subject: [PATCH 1/4] Unittest - Fix newlines should be interpreted in printed output --- test/simpletap/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/simpletap/__init__.py b/test/simpletap/__init__.py index afaacc87e..7dd4cfc18 100644 --- a/test/simpletap/__init__.py +++ b/test/simpletap/__init__.py @@ -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) From 02935726ba6540ed391d15ce68b07de613fc2b87 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Thu, 24 Jul 2014 13:21:38 +0100 Subject: [PATCH 2/4] No-color theme / Template theme * This theme is meant to be used while testing colorsthough users may find it useful as a blank template for their own themes --- doc/rc/no-color.theme | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 doc/rc/no-color.theme diff --git a/doc/rc/no-color.theme b/doc/rc/no-color.theme new file mode 100644 index 000000000..d28fc7dce --- /dev/null +++ b/doc/rc/no-color.theme @@ -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= From d15c98deda170fd233138cfaa77a162c35bf2fef Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Thu, 24 Jul 2014 15:04:34 +0100 Subject: [PATCH 3/4] Unittest - Testcase for bug TW-1379 --- test/tw-1379.t | 136 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 test/tw-1379.t diff --git a/test/tw-1379.t b/test/tw-1379.t new file mode 100755 index 000000000..923a8d712 --- /dev/null +++ b/test/tw-1379.t @@ -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 From 22efbe3f74ee7ef01e982454e2dfceaf407c33d5 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Thu, 24 Jul 2014 15:06:02 +0100 Subject: [PATCH 4/4] Unittest - Testcase for bug TW-1381 --- test/tw-1381.t | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 test/tw-1381.t diff --git a/test/tw-1381.t b/test/tw-1381.t new file mode 100755 index 000000000..1c3557ad5 --- /dev/null +++ b/test/tw-1381.t @@ -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