Commit f0f319ea authored by Bram Schoenmakers's avatar Bram Schoenmakers

Make testcases runnable from unittest discover.

parent 6e02b2fd
...@@ -185,3 +185,6 @@ class AddCommandTest(CommandTest.CommandTest): ...@@ -185,3 +185,6 @@ class AddCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -79,3 +79,6 @@ class AppendCommandTest(CommandTest.CommandTest): ...@@ -79,3 +79,6 @@ class AppendCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -21,7 +21,7 @@ from topydo.lib.TodoList import TodoList ...@@ -21,7 +21,7 @@ from topydo.lib.TodoList import TodoList
class ArchiveCommandTest(CommandTest.CommandTest): class ArchiveCommandTest(CommandTest.CommandTest):
def test_archive(self): def test_archive(self):
todolist = TestFacilities.load_file_to_todolist("data/ArchiveCommandTest.txt") todolist = TestFacilities.load_file_to_todolist("test/data/ArchiveCommandTest.txt")
archive = TodoList([]) archive = TodoList([])
command = ArchiveCommand(todolist, archive) command = ArchiveCommand(todolist, archive)
...@@ -32,3 +32,6 @@ class ArchiveCommandTest(CommandTest.CommandTest): ...@@ -32,3 +32,6 @@ class ArchiveCommandTest(CommandTest.CommandTest):
self.assertEquals(str(todolist), "x Not complete\n(C) Active") self.assertEquals(str(todolist), "x Not complete\n(C) Active")
self.assertEquals(str(archive), "x 2014-10-19 Complete\nx 2014-10-20 Another one complete") self.assertEquals(str(archive), "x 2014-10-19 Complete\nx 2014-10-20 Another one complete")
if __name__ == '__main__':
unittest.main()
...@@ -35,3 +35,6 @@ class CommandTest(unittest.TestCase): ...@@ -35,3 +35,6 @@ class CommandTest(unittest.TestCase):
def error(self, p_error): def error(self, p_error):
if p_error: if p_error:
self.errors += escape_ansi(p_error + "\n") self.errors += escape_ansi(p_error + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -20,10 +20,13 @@ from topydo.lib.Config import config ...@@ -20,10 +20,13 @@ from topydo.lib.Config import config
class ConfigTest(unittest.TestCase): class ConfigTest(unittest.TestCase):
def test_config1(self): def test_config1(self):
self.assertEquals(config("data/config1").default_command(), 'do') self.assertEquals(config("test/data/config1").default_command(), 'do')
def test_config2(self): def test_config2(self):
self.assertNotEquals(config("").default_command(), 'do') self.assertNotEquals(config("").default_command(), 'do')
def test_config3(self): def test_config3(self):
self.assertTrue(config("data/config2").ignore_weekends()) self.assertTrue(config("test/data/config2").ignore_weekends())
if __name__ == '__main__':
unittest.main()
...@@ -112,3 +112,6 @@ class DeleteCommandTest(CommandTest.CommandTest): ...@@ -112,3 +112,6 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -246,3 +246,6 @@ class DepCommandTest(CommandTest.CommandTest): ...@@ -246,3 +246,6 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -77,3 +77,6 @@ class DepriCommandTest(CommandTest.CommandTest): ...@@ -77,3 +77,6 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -252,3 +252,6 @@ class DoCommandTest(CommandTest.CommandTest): ...@@ -252,3 +252,6 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
...@@ -167,3 +167,6 @@ class GraphTest(unittest.TestCase): ...@@ -167,3 +167,6 @@ class GraphTest(unittest.TestCase):
def test_dot_output_without_labels(self): def test_dot_output_without_labels(self):
out = 'digraph g {\n 1\n 1 -> 2\n 1 -> 3\n 2\n 2 -> 4\n 3\n 3 -> 5\n 4\n 4 -> 3\n 4 -> 6\n 5\n 6\n 6 -> 2\n}\n' out = 'digraph g {\n 1\n 1 -> 2\n 1 -> 3\n 2\n 2 -> 4\n 3\n 3 -> 5\n 4\n 4 -> 3\n 4 -> 6\n 5\n 6\n 6 -> 2\n}\n'
self.assertEquals(self.graph.dot(False), out) self.assertEquals(self.graph.dot(False), out)
if __name__ == '__main__':
unittest.main()
...@@ -38,3 +38,6 @@ class ImportanceTest(unittest.TestCase): ...@@ -38,3 +38,6 @@ class ImportanceTest(unittest.TestCase):
today_str = date.today().isoformat() today_str = date.today().isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str) todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str)
self.assertEqual(importance(todo), 8) self.assertEqual(importance(todo), 8)
if __name__ == '__main__':
unittest.main()
...@@ -22,7 +22,7 @@ import TestFacilities ...@@ -22,7 +22,7 @@ import TestFacilities
class ListCommandTest(CommandTest.CommandTest): class ListCommandTest(CommandTest.CommandTest):
def setUp(self): def setUp(self):
super(ListCommandTest, self).setUp() super(ListCommandTest, self).setUp()
self.todolist = TestFacilities.load_file_to_todolist("data/ListCommandTest.txt") self.todolist = TestFacilities.load_file_to_todolist("test/data/ListCommandTest.txt")
def tearDown(self): def tearDown(self):
# restore to the default configuration in case a custom one was set # restore to the default configuration in case a custom one was set
...@@ -101,7 +101,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -101,7 +101,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list11(self): def test_list11(self):
config("data/listcommand.conf") config("test/data/listcommand.conf")
command = ListCommand(["project"], self.todolist, self.out, self.error) command = ListCommand(["project"], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -111,7 +111,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -111,7 +111,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list12(self): def test_list12(self):
config("data/listcommand.conf") config("test/data/listcommand.conf")
command = ListCommand(["-x", "project"], self.todolist, self.out, self.error) command = ListCommand(["-x", "project"], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -129,7 +129,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -129,7 +129,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list14(self): def test_list14(self):
config("data/listcommand2.conf") config("test/data/listcommand2.conf")
command = ListCommand([], self.todolist, self.out, self.error) command = ListCommand([], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -147,7 +147,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -147,7 +147,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list16(self): def test_list16(self):
config("data/todolist-uid.conf") config("test/data/todolist-uid.conf")
command = ListCommand([], self.todolist, self.out, self.error) command = ListCommand([], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -170,3 +170,6 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -170,3 +170,6 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -20,7 +20,7 @@ from topydo.lib.ListContextCommand import ListContextCommand ...@@ -20,7 +20,7 @@ from topydo.lib.ListContextCommand import ListContextCommand
class ListContextCommandTest(CommandTest.CommandTest): class ListContextCommandTest(CommandTest.CommandTest):
def test_contexts1(self): def test_contexts1(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt") todolist = TestFacilities.load_file_to_todolist("test/data/TodoListTest.txt")
command = ListContextCommand([""], todolist, self.out, self.error) command = ListContextCommand([""], todolist, self.out, self.error)
command.execute() command.execute()
...@@ -28,7 +28,7 @@ class ListContextCommandTest(CommandTest.CommandTest): ...@@ -28,7 +28,7 @@ class ListContextCommandTest(CommandTest.CommandTest):
self.assertFalse(self.errors) self.assertFalse(self.errors)
def test_contexts2(self): def test_contexts2(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt") todolist = TestFacilities.load_file_to_todolist("test/data/TodoListTest.txt")
command = ListContextCommand(["aaa"], todolist, self.out, self.error) command = ListContextCommand(["aaa"], todolist, self.out, self.error)
command.execute() command.execute()
...@@ -41,3 +41,6 @@ class ListContextCommandTest(CommandTest.CommandTest): ...@@ -41,3 +41,6 @@ class ListContextCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -20,7 +20,7 @@ from topydo.lib.ListProjectCommand import ListProjectCommand ...@@ -20,7 +20,7 @@ from topydo.lib.ListProjectCommand import ListProjectCommand
class ListProjectCommandTest(CommandTest.CommandTest): class ListProjectCommandTest(CommandTest.CommandTest):
def test_projects1(self): def test_projects1(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt") todolist = TestFacilities.load_file_to_todolist("test/data/TodoListTest.txt")
command = ListProjectCommand([""], todolist, self.out, self.error) command = ListProjectCommand([""], todolist, self.out, self.error)
command.execute() command.execute()
...@@ -28,7 +28,7 @@ class ListProjectCommandTest(CommandTest.CommandTest): ...@@ -28,7 +28,7 @@ class ListProjectCommandTest(CommandTest.CommandTest):
self.assertFalse(self.errors) self.assertFalse(self.errors)
def test_projects2(self): def test_projects2(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt") todolist = TestFacilities.load_file_to_todolist("test/data/TodoListTest.txt")
command = ListProjectCommand(["aaa"], todolist, self.out, self.error) command = ListProjectCommand(["aaa"], todolist, self.out, self.error)
command.execute() command.execute()
...@@ -41,3 +41,6 @@ class ListProjectCommandTest(CommandTest.CommandTest): ...@@ -41,3 +41,6 @@ class ListProjectCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -170,3 +170,6 @@ class PostponeCommandTest(CommandTest.CommandTest): ...@@ -170,3 +170,6 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -106,3 +106,6 @@ class PriorityCommandTest(CommandTest.CommandTest): ...@@ -106,3 +106,6 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -135,3 +135,6 @@ class RecurrenceTest(unittest.TestCase): ...@@ -135,3 +135,6 @@ class RecurrenceTest(unittest.TestCase):
def test_no_recurrence(self): def test_no_recurrence(self):
self.todo.remove_tag('rec') self.todo.remove_tag('rec')
self.assertRaises(NoRecurrenceException,advance_recurring_todo,self.todo) self.assertRaises(NoRecurrenceException,advance_recurring_todo,self.todo)
if __name__ == '__main__':
unittest.main()
...@@ -108,3 +108,6 @@ class RelativeDateTester(unittest.TestCase): ...@@ -108,3 +108,6 @@ class RelativeDateTester(unittest.TestCase):
def test_offset1(self): def test_offset1(self):
result = relative_date_to_date('1d', self.tomorrow) result = relative_date_to_date('1d', self.tomorrow)
self.assertEquals(result, date.today() + timedelta(2)) self.assertEquals(result, date.today() + timedelta(2))
if __name__ == '__main__':
unittest.main()
...@@ -22,7 +22,7 @@ import TestFacilities ...@@ -22,7 +22,7 @@ import TestFacilities
class SortCommandTest(CommandTest.CommandTest): class SortCommandTest(CommandTest.CommandTest):
def setUp(self): def setUp(self):
super(SortCommandTest, self).setUp() super(SortCommandTest, self).setUp()
self.todolist = TestFacilities.load_file_to_todolist("data/SorterTest1.txt") self.todolist = TestFacilities.load_file_to_todolist("test/data/SorterTest1.txt")
def tearDown(self): def tearDown(self):
# restore to the default configuration in case a custom one was set # restore to the default configuration in case a custom one was set
...@@ -43,7 +43,7 @@ class SortCommandTest(CommandTest.CommandTest): ...@@ -43,7 +43,7 @@ class SortCommandTest(CommandTest.CommandTest):
def test_sort3(self): def test_sort3(self):
""" Check that order does not influence the UID of a todo. """ """ Check that order does not influence the UID of a todo. """
config("data/todolist-uid.conf") config("test/data/todolist-uid.conf")
todo1 = self.todolist.todo('tpi') todo1 = self.todolist.todo('tpi')
command = SortCommand(["text"], self.todolist, self.out, self.error) command = SortCommand(["text"], self.todolist, self.out, self.error)
...@@ -58,3 +58,6 @@ class SortCommandTest(CommandTest.CommandTest): ...@@ -58,3 +58,6 @@ class SortCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -38,21 +38,21 @@ class SorterTest(unittest.TestCase): ...@@ -38,21 +38,21 @@ class SorterTest(unittest.TestCase):
def test_sort1(self): def test_sort1(self):
""" Alphabetically sorted """ """ Alphabetically sorted """
sorter = Sorter('text') sorter = Sorter('text')
self.sort_file('data/SorterTest1.txt', 'data/SorterTest1-result.txt', sorter) self.sort_file('test/data/SorterTest1.txt', 'test/data/SorterTest1-result.txt', sorter)
def test_sort2a(self): def test_sort2a(self):
""" """
Ascendingly sorted by priority. Also checks stableness of the sort. Ascendingly sorted by priority. Also checks stableness of the sort.
""" """
sorter = Sorter('prio') sorter = Sorter('prio')
self.sort_file('data/SorterTest2.txt', 'data/SorterTest2-result.txt', sorter) self.sort_file('test/data/SorterTest2.txt', 'test/data/SorterTest2-result.txt', sorter)
def test_sort2b(self): def test_sort2b(self):
""" """
Ascendingly sorted by priority. Also checks stableness of the sort. Ascendingly sorted by priority. Also checks stableness of the sort.
""" """
sorter = Sorter('asc:prio') sorter = Sorter('asc:prio')
self.sort_file('data/SorterTest2.txt', 'data/SorterTest2-result.txt', sorter) self.sort_file('test/data/SorterTest2.txt', 'test/data/SorterTest2-result.txt', sorter)
def test_sort3(self): def test_sort3(self):
""" """
...@@ -60,32 +60,32 @@ class SorterTest(unittest.TestCase): ...@@ -60,32 +60,32 @@ class SorterTest(unittest.TestCase):
sort. sort.
""" """
sorter = Sorter('desc:prio') sorter = Sorter('desc:prio')
self.sort_file('data/SorterTest3.txt', 'data/SorterTest3-result.txt', sorter) self.sort_file('test/data/SorterTest3.txt', 'test/data/SorterTest3-result.txt', sorter)
def test_sort4(self): def test_sort4(self):
""" Ascendingly sorted by due date """ """ Ascendingly sorted by due date """
sorter = Sorter(config().tag_due()) sorter = Sorter(config().tag_due())
self.sort_file('data/SorterTest4.txt', 'data/SorterTest4-result.txt', sorter) self.sort_file('test/data/SorterTest4.txt', 'test/data/SorterTest4-result.txt', sorter)
def test_sort5(self): def test_sort5(self):
""" Descendingly sorted by due date """ """ Descendingly sorted by due date """
sorter = Sorter('desc:due') sorter = Sorter('desc:due')
self.sort_file('data/SorterTest5.txt', 'data/SorterTest5-result.txt', sorter) self.sort_file('test/data/SorterTest5.txt', 'test/data/SorterTest5-result.txt', sorter)
def test_sort6(self): def test_sort6(self):
""" Ascendingly sorted by creation date """ """ Ascendingly sorted by creation date """
sorter = Sorter('creation') sorter = Sorter('creation')
self.sort_file('data/SorterTest6.txt', 'data/SorterTest6-result.txt', sorter) self.sort_file('test/data/SorterTest6.txt', 'test/data/SorterTest6-result.txt', sorter)
def test_sort7(self): def test_sort7(self):
""" Ascendingly sorted by completion date. """ """ Ascendingly sorted by completion date. """
sorter = Sorter('completion') sorter = Sorter('completion')
self.sort_file('data/SorterTest7.txt', 'data/SorterTest7-result.txt', sorter) self.sort_file('test/data/SorterTest7.txt', 'test/data/SorterTest7-result.txt', sorter)
def test_sort8(self): def test_sort8(self):
""" Descendingly sorted by importance """ """ Descendingly sorted by importance """
sorter = Sorter('desc:importance') sorter = Sorter('desc:importance')
self.sort_file('data/SorterTest8.txt', 'data/SorterTest8-result.txt', sorter) self.sort_file('test/data/SorterTest8.txt', 'test/data/SorterTest8-result.txt', sorter)
def test_sort9(self): def test_sort9(self):
""" """
...@@ -93,22 +93,22 @@ class SorterTest(unittest.TestCase): ...@@ -93,22 +93,22 @@ class SorterTest(unittest.TestCase):
ascending priority. ascending priority.
""" """
sorter = Sorter('desc:importance,priority') sorter = Sorter('desc:importance,priority')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter) self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
def test_sort10(self): def test_sort10(self):
""" Deal with garbage input. """ """ Deal with garbage input. """
sorter = Sorter('') sorter = Sorter('')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9.txt', sorter) self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9.txt', sorter)
def test_sort11(self): def test_sort11(self):
""" Deal with garbage input. """ """ Deal with garbage input. """
sorter = Sorter('fnord') sorter = Sorter('fnord')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9.txt', sorter) self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9.txt', sorter)
def test_sort12(self): def test_sort12(self):
""" Deal with garbage input. """ """ Deal with garbage input. """
sorter = Sorter('desc:importance,,priority') sorter = Sorter('desc:importance,,priority')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter) self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
def test_sort13(self): def test_sort13(self):
""" """
...@@ -118,14 +118,14 @@ class SorterTest(unittest.TestCase): ...@@ -118,14 +118,14 @@ class SorterTest(unittest.TestCase):
dependencies the average importance should be equal. dependencies the average importance should be equal.
""" """
sorter = Sorter('desc:importance-avg') sorter = Sorter('desc:importance-avg')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter) self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
def test_sort14(self): def test_sort14(self):
sorter = Sorter('desc:importance-average') sorter = Sorter('desc:importance-average')
todolist = load_file_to_todolist('data/SorterTest10.txt') todolist = load_file_to_todolist('test/data/SorterTest10.txt')
view = todolist.view(sorter, []) view = todolist.view(sorter, [])
result = load_file('data/SorterTest10-result.txt') result = load_file('test/data/SorterTest10-result.txt')
self.assertEquals(str(view), todolist_to_string(result)) self.assertEquals(str(view), todolist_to_string(result))
...@@ -136,9 +136,9 @@ class SorterTest(unittest.TestCase): ...@@ -136,9 +136,9 @@ class SorterTest(unittest.TestCase):
""" """
sorter = Sorter('desc:importance-average') sorter = Sorter('desc:importance-average')
todolist = load_file_to_todolist('data/SorterTest11.txt') todolist = load_file_to_todolist('test/data/SorterTest11.txt')
view = todolist.view(sorter, []) view = todolist.view(sorter, [])
result = load_file('data/SorterTest11-result.txt') result = load_file('test/data/SorterTest11-result.txt')
self.assertEquals(str(view), todolist_to_string(result)) self.assertEquals(str(view), todolist_to_string(result))
...@@ -148,8 +148,11 @@ class SorterTest(unittest.TestCase): ...@@ -148,8 +148,11 @@ class SorterTest(unittest.TestCase):
""" """
sorter = Sorter('desc:importance,desc:prio') sorter = Sorter('desc:importance,desc:prio')
todolist = load_file_to_todolist('data/SorterTest12.txt') todolist = load_file_to_todolist('test/data/SorterTest12.txt')
view = todolist.view(sorter, []) view = todolist.view(sorter, [])
result = load_file('data/SorterTest12-result.txt') result = load_file('test/data/SorterTest12-result.txt')
self.assertEquals(str(view), todolist_to_string(result)) self.assertEquals(str(view), todolist_to_string(result))
if __name__ == '__main__':
unittest.main()
...@@ -199,3 +199,6 @@ class TagCommandTest(CommandTest.CommandTest): ...@@ -199,3 +199,6 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "") self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEquals(self.errors, command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
...@@ -20,6 +20,9 @@ from TestFacilities import load_file ...@@ -20,6 +20,9 @@ from TestFacilities import load_file
class TodoFileTest(unittest.TestCase): class TodoFileTest(unittest.TestCase):
def test_empty_file(self): def test_empty_file(self):
todofile = load_file('data/TodoFileTest1.txt') todofile = load_file('test/data/TodoFileTest1.txt')
self.assertEquals(len(todofile), 0) self.assertEquals(len(todofile), 0)
if __name__ == '__main__':
unittest.main()
...@@ -27,7 +27,7 @@ from topydo.lib.TodoList import TodoList ...@@ -27,7 +27,7 @@ from topydo.lib.TodoList import TodoList
class TodoListTester(unittest.TestCase): class TodoListTester(unittest.TestCase):
def setUp(self): def setUp(self):
self.todofile = TodoFile('data/TodoListTest.txt') self.todofile = TodoFile('test/data/TodoListTest.txt')
lines = [line for line in self.todofile.read() \ lines = [line for line in self.todofile.read() \
if re.search(r'\S', line)] if re.search(r'\S', line)]
self.text = ''.join(lines) self.text = ''.join(lines)
...@@ -197,13 +197,13 @@ class TodoListTester(unittest.TestCase): ...@@ -197,13 +197,13 @@ class TodoListTester(unittest.TestCase):
self.assertEquals(todo.source(), "(D) Bar @Context1 +Project2") self.assertEquals(todo.source(), "(D) Bar @Context1 +Project2")
def test_uid1(self): def test_uid1(self):
config("data/todolist-uid.conf") config("test/data/todolist-uid.conf")
self.assertEquals(self.todolist.todo('6iu').source(), "(C) Foo @Context2 Not@Context +Project1 Not+Project") self.assertEquals(self.todolist.todo('6iu').source(), "(C) Foo @Context2 Not@Context +Project1 Not+Project")
def test_uid2(self): def test_uid2(self):
""" Changing the priority should not change the identifier. """ """ Changing the priority should not change the identifier. """
config("data/todolist-uid.conf") config("test/data/todolist-uid.conf")
todo = self.todolist.todo('6iu') todo = self.todolist.todo('6iu')
self.todolist.set_priority(todo, 'B') self.todolist.set_priority(todo, 'B')
...@@ -320,3 +320,6 @@ class TodoListCleanDependencyTester(unittest.TestCase): ...@@ -320,3 +320,6 @@ class TodoListCleanDependencyTester(unittest.TestCase):
self.assertFalse(self.todolist.todo(2).has_tag('p')) self.assertFalse(self.todolist.todo(2).has_tag('p'))
self.assertTrue(self.todolist.todo(2).has_tag('id', '2')) self.assertTrue(self.todolist.todo(2).has_tag('id', '2'))
self.assertTrue(self.todolist.todo(3).has_tag('p', '2')) self.assertTrue(self.todolist.todo(3).has_tag('p', '2'))
if __name__ == '__main__':
unittest.main()
...@@ -85,3 +85,6 @@ class TodoTest(unittest.TestCase): ...@@ -85,3 +85,6 @@ class TodoTest(unittest.TestCase):
def test_length3(self): def test_length3(self):
todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02") todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
self.assertEqual(todo.length(), 1) self.assertEqual(todo.length(), 1)
if __name__ == '__main__':
unittest.main()
...@@ -25,8 +25,8 @@ from topydo.lib.TodoList import TodoList ...@@ -25,8 +25,8 @@ from topydo.lib.TodoList import TodoList
class ViewTest(unittest.TestCase): class ViewTest(unittest.TestCase):
def test_view(self): def test_view(self):
""" Check filters and printer for views. """ """ Check filters and printer for views. """
todofile = TodoFile('data/FilterTest1.txt') todofile = TodoFile('test/data/FilterTest1.txt')
ref = load_file('data/ViewTest1-result.txt') ref = load_file('test/data/ViewTest1-result.txt')
todolist = TodoList(todofile.read()) todolist = TodoList(todofile.read())
sorter = Sorter('text') sorter = Sorter('text')
...@@ -35,3 +35,6 @@ class ViewTest(unittest.TestCase): ...@@ -35,3 +35,6 @@ class ViewTest(unittest.TestCase):
self.assertEquals(str(view), todolist_to_string(ref)) self.assertEquals(str(view), todolist_to_string(ref))
if __name__ == '__main__':
unittest.main()
#!/bin/bash
export PYTHONPATH=..
if [ -n "$1" ]; then
TESTS=$1
else
TESTS="*Test.py"
fi
for TEST in $TESTS; do
python -m unittest "${TEST%\.*}" # strip the .py extension
done
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