Commit b060ea9e authored by Kirill Smelkov's avatar Kirill Smelkov

colors: Default to 256

parent b59fcfca
...@@ -45,7 +45,7 @@ class ConfigTest(TopydoTest): ...@@ -45,7 +45,7 @@ class ConfigTest(TopydoTest):
""" Bad colour switch value. """ """ Bad colour switch value. """
# boolean settings must first be typecast to integers, because all # boolean settings must first be typecast to integers, because all
# strings evaulate to 'True' # strings evaulate to 'True'
self.assertEqual(config("test/data/ConfigTest4.conf").colors(), 16) self.assertEqual(config("test/data/ConfigTest4.conf").colors(), 256)
def test_config06(self): def test_config06(self):
""" Bad auto creation date switch value. """ """ Bad auto creation date switch value. """
......
...@@ -348,9 +348,9 @@ class DepCommandTest(CommandTest): ...@@ -348,9 +348,9 @@ class DepCommandTest(CommandTest):
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, """digraph topydo { self.assertEqual(self.output, """digraph topydo {
node [ shape="none" margin="0" fontsize="9" fontname="Helvetica" ] node [ shape="none" margin="0" fontsize="9" fontname="Helvetica" ]
_2 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>2</B></TD><TD BALIGN="LEFT"><B>Bar</B></TD></TR></TABLE>> style=filled fillcolor="#008000" fontcolor="#ffffff"] _2 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>2</B></TD><TD BALIGN="LEFT"><B>Bar</B></TD></TR></TABLE>> style=filled fillcolor="#005f00" fontcolor="#ffffff"]
_3 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>3</B></TD><TD BALIGN="LEFT"><B>Baz</B></TD></TR></TABLE>> style=filled fillcolor="#008000" fontcolor="#ffffff"] _3 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>3</B></TD><TD BALIGN="LEFT"><B>Baz</B></TD></TR></TABLE>> style=filled fillcolor="#005f00" fontcolor="#ffffff"]
_1 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>1</B></TD><TD BALIGN="LEFT"><B>Foo</B></TD></TR></TABLE>> style=filled fillcolor="#008000" fontcolor="#ffffff"] _1 [label=<<TABLE CELLBORDER="0" CELLSPACING="1" VALIGN="top"><TR><TD><B>1</B></TD><TD BALIGN="LEFT"><B>Foo</B></TD></TR></TABLE>> style=filled fillcolor="#005f00" fontcolor="#ffffff"]
_1 -> _2 _1 -> _2
_1 -> _3 _1 -> _3
}\n }\n
......
...@@ -29,6 +29,7 @@ from topydo.lib.TodoList import TodoList ...@@ -29,6 +29,7 @@ from topydo.lib.TodoList import TodoList
from .command_testcase import CommandTest from .command_testcase import CommandTest
from .facilities import load_file_to_todolist from .facilities import load_file_to_todolist
from .test_progress_color import set_16_colors
# We're searching for 'mock' # We're searching for 'mock'
# 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2 # 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2
...@@ -596,6 +597,7 @@ class ListCommandIcalTest(CommandTest): ...@@ -596,6 +597,7 @@ class ListCommandIcalTest(CommandTest):
class ListCommandDotTest(CommandTest): class ListCommandDotTest(CommandTest):
def setUp(self): def setUp(self):
self.maxDiff = None self.maxDiff = None
set_16_colors()
def test_dot(self): def test_dot(self):
todolist = load_file_to_todolist("test/data/ListCommandDotTest.txt") todolist = load_file_to_todolist("test/data/ListCommandDotTest.txt")
......
...@@ -29,16 +29,21 @@ from .topydo_testcase import TopydoTest ...@@ -29,16 +29,21 @@ from .topydo_testcase import TopydoTest
def set_256_colors(): def set_256_colors():
config(p_overrides={('topydo', 'colors'): '256'}) config(p_overrides={('topydo', 'colors'): '256'})
def set_16_colors():
config(p_overrides={('topydo', 'colors'): '16'})
@freeze_time('2016, 01, 01') @freeze_time('2016, 01, 01')
class ProgressColorTest(TopydoTest): class ProgressColorTest(TopydoTest):
def test_progress1(self): def test_progress1(self):
""" Test progress of task with no length """ """ Test progress of task with no length """
set_16_colors()
color = progress_color(Todo('Foo')) color = progress_color(Todo('Foo'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
def test_progress2(self): def test_progress2(self):
""" Test progress of task with no length (but with creation date). """ """ Test progress of task with no length (but with creation date). """
set_16_colors()
color = progress_color(Todo('2016-02-11 Foo')) color = progress_color(Todo('2016-02-11 Foo'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -58,6 +63,7 @@ class ProgressColorTest(TopydoTest): ...@@ -58,6 +63,7 @@ class ProgressColorTest(TopydoTest):
def test_progress5(self): def test_progress5(self):
""" Test overdue tasks """ """ Test overdue tasks """
set_16_colors()
color = progress_color(Todo('Foo due:2015-12-31')) color = progress_color(Todo('Foo due:2015-12-31'))
self.assertEqual(color.color, 1) self.assertEqual(color.color, 1)
...@@ -70,6 +76,7 @@ class ProgressColorTest(TopydoTest): ...@@ -70,6 +76,7 @@ class ProgressColorTest(TopydoTest):
def test_progress7(self): def test_progress7(self):
""" Due today """ """ Due today """
set_16_colors()
color = progress_color(Todo('Foo due:2016-01-01')) color = progress_color(Todo('Foo due:2016-01-01'))
self.assertEqual(color.color, 3) self.assertEqual(color.color, 3)
...@@ -82,6 +89,7 @@ class ProgressColorTest(TopydoTest): ...@@ -82,6 +89,7 @@ class ProgressColorTest(TopydoTest):
def test_progress9(self): def test_progress9(self):
""" Due tomorrow """ """ Due tomorrow """
set_16_colors()
color = progress_color(Todo('Foo due:2016-01-02')) color = progress_color(Todo('Foo due:2016-01-02'))
# a length of 14 days is assumed # a length of 14 days is assumed
self.assertEqual(color.color, 3) self.assertEqual(color.color, 3)
...@@ -94,6 +102,7 @@ class ProgressColorTest(TopydoTest): ...@@ -94,6 +102,7 @@ class ProgressColorTest(TopydoTest):
def test_progress11(self): def test_progress11(self):
""" Due tomorrow (creation date) """ """ Due tomorrow (creation date) """
set_16_colors()
color = progress_color(Todo('2016-01-01 Foo due:2016-01-02')) color = progress_color(Todo('2016-01-01 Foo due:2016-01-02'))
# a length of 14 days is assumed # a length of 14 days is assumed
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -106,6 +115,7 @@ class ProgressColorTest(TopydoTest): ...@@ -106,6 +115,7 @@ class ProgressColorTest(TopydoTest):
def test_progress13(self): def test_progress13(self):
""" Due tomorrow (recurrence) """ """ Due tomorrow (recurrence) """
set_16_colors()
color = progress_color(Todo('Foo due:2016-01-02 rec:1d')) color = progress_color(Todo('Foo due:2016-01-02 rec:1d'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -117,6 +127,7 @@ class ProgressColorTest(TopydoTest): ...@@ -117,6 +127,7 @@ class ProgressColorTest(TopydoTest):
def test_progress15(self): def test_progress15(self):
""" Due tomorrow (creation date + recurrence) """ """ Due tomorrow (creation date + recurrence) """
set_16_colors()
color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:1d')) color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:1d'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -128,6 +139,7 @@ class ProgressColorTest(TopydoTest): ...@@ -128,6 +139,7 @@ class ProgressColorTest(TopydoTest):
def test_progress17(self): def test_progress17(self):
""" Due tomorrow (creation date + recurrence + start date) """ """ Due tomorrow (creation date + recurrence + start date) """
set_16_colors()
color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:1d t:2016-01-02')) color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:1d t:2016-01-02'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -139,6 +151,7 @@ class ProgressColorTest(TopydoTest): ...@@ -139,6 +151,7 @@ class ProgressColorTest(TopydoTest):
def test_progress19(self): def test_progress19(self):
""" Due tomorrow (creation date + strict recurrence + start date) """ """ Due tomorrow (creation date + strict recurrence + start date) """
set_16_colors()
color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:+1d t:2016-01-02')) color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 rec:+1d t:2016-01-02'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -150,6 +163,7 @@ class ProgressColorTest(TopydoTest): ...@@ -150,6 +163,7 @@ class ProgressColorTest(TopydoTest):
def test_progress21(self): def test_progress21(self):
""" Due tomorrow (creation date + start date) """ """ Due tomorrow (creation date + start date) """
set_16_colors()
color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 t:2016-01-02')) color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 t:2016-01-02'))
self.assertEqual(color.color, 2) self.assertEqual(color.color, 2)
...@@ -161,6 +175,7 @@ class ProgressColorTest(TopydoTest): ...@@ -161,6 +175,7 @@ class ProgressColorTest(TopydoTest):
def test_progress23(self): def test_progress23(self):
""" Due tomorrow (creation date + start date) """ """ Due tomorrow (creation date + start date) """
set_16_colors()
color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 t:2015-12-31')) color = progress_color(Todo('2016-12-01 Foo due:2016-01-02 t:2015-12-31'))
self.assertEqual(color.color, 10) self.assertEqual(color.color, 10)
...@@ -172,6 +187,7 @@ class ProgressColorTest(TopydoTest): ...@@ -172,6 +187,7 @@ class ProgressColorTest(TopydoTest):
def test_progress25(self): def test_progress25(self):
""" Start date after due date """ """ Start date after due date """
set_16_colors()
color = progress_color(Todo('Foo due:2016-01-02 t:2016-01-03')) color = progress_color(Todo('Foo due:2016-01-02 t:2016-01-03'))
# a length of 14 days is assumed # a length of 14 days is assumed
self.assertEqual(color.color, 3) self.assertEqual(color.color, 3)
...@@ -197,6 +213,7 @@ class ProgressColorTest(TopydoTest): ...@@ -197,6 +213,7 @@ class ProgressColorTest(TopydoTest):
"Bar p:1", "Bar p:1",
]) ])
set_16_colors()
color = progress_color(todolist.todo(2)) color = progress_color(todolist.todo(2))
# color the subitem red because it has no color of its own and its # color the subitem red because it has no color of its own and its
...@@ -210,6 +227,7 @@ class ProgressColorTest(TopydoTest): ...@@ -210,6 +227,7 @@ class ProgressColorTest(TopydoTest):
"Bar p:1 t:2016-01-01 due:2016-01-01", "Bar p:1 t:2016-01-01 due:2016-01-01",
]) ])
set_16_colors()
color = progress_color(todolist.todo(2)) color = progress_color(todolist.todo(2))
# the parent has no influence here # the parent has no influence here
...@@ -222,6 +240,7 @@ class ProgressColorTest(TopydoTest): ...@@ -222,6 +240,7 @@ class ProgressColorTest(TopydoTest):
"Bar p:1", "Bar p:1",
]) ])
set_16_colors()
color = progress_color(todolist.todo(2)) color = progress_color(todolist.todo(2))
# the parent has no influence here # the parent has no influence here
......
...@@ -287,6 +287,7 @@ class RevertCommandTest(CommandTest): ...@@ -287,6 +287,7 @@ class RevertCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_revert_ls(self): def test_revert_ls(self):
# FIXME fails with colors=256
backup = BackupSimulator(self.todolist, self.archive, '1', ['add One']) backup = BackupSimulator(self.todolist, self.archive, '1', ['add One'])
command_executer(AddCommand, ["One"], self.todolist, None, self.out, self.error, None) command_executer(AddCommand, ["One"], self.todolist, None, self.out, self.error, None)
backup.save(self.todolist) backup.save(self.todolist)
......
...@@ -236,7 +236,7 @@ class _Config: ...@@ -236,7 +236,7 @@ class _Config:
colors = lookup[self.defaults['topydo']['colors'].lower()] # pylint: disable=no-member colors = lookup[self.defaults['topydo']['colors'].lower()] # pylint: disable=no-member
except KeyError: except KeyError:
# for invalid values or 'auto' # for invalid values or 'auto'
colors = 16 if p_hint_possible else 0 colors = 256 if p_hint_possible else 0
# disable colors when no colors are enforced on the commandline and # disable colors when no colors are enforced on the commandline and
# color support is determined automatically # color support is determined automatically
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment