Commit 7da73100 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Make all other tests also independent of possible user configuration.

parent f0f319ea
......@@ -16,18 +16,15 @@
import unittest
from topydo.lib.Config import config
from topydo.lib.Utils import escape_ansi
import TopydoTest
class CommandTest(unittest.TestCase):
class CommandTest(TopydoTest.TopydoTest):
def __init__(self, *args, **kwargs):
super(CommandTest, self).__init__(*args, **kwargs)
self.output = ""
self.errors = ""
def setUp(self):
config("")
def out(self, p_output):
if p_output:
self.output += escape_ansi(p_output + "\n")
......
......@@ -17,8 +17,9 @@
import unittest
from topydo.lib.Config import config
import TopydoTest
class ConfigTest(unittest.TestCase):
class ConfigTest(TopydoTest.TopydoTest):
def test_config1(self):
self.assertEquals(config("test/data/config1").default_command(), 'do')
......
......@@ -22,8 +22,9 @@ import unittest
from topydo.lib import Filter
from TestFacilities import load_file, todolist_to_string, load_file_to_todolist
from topydo.lib.Todo import Todo
import TopydoTest
class FilterTest(unittest.TestCase):
class FilterTest(TopydoTest.TopydoTest):
def test_filter3(self):
todo = Todo("(C) Relevant")
relevance = Filter.RelevanceFilter()
......@@ -294,8 +295,10 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
class OrdinalTagFilterTest(unittest.TestCase):
class OrdinalTagFilterTest(TopydoTest.TopydoTest):
def setUp(self):
super(OrdinalTagFilterTest, self).setUp()
today = date.today()
tomorrow = today + timedelta(1)
......
......@@ -17,9 +17,12 @@
import unittest
from topydo.lib.Graph import DirectedGraph
import TopydoTest
class GraphTest(unittest.TestCase):
class GraphTest(TopydoTest.TopydoTest):
def setUp(self):
super(GraphTest, self).setUp()
self.graph = DirectedGraph()
self.graph.add_edge(1, 2, 1)
......
......@@ -20,8 +20,9 @@ import unittest
from topydo.lib.Config import config
from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo
import TopydoTest
class ImportanceTest(unittest.TestCase):
class ImportanceTest(TopydoTest.TopydoTest):
def test_importance1(self):
todo = Todo("Foo")
self.assertEqual(importance(todo), 2)
......
......@@ -20,9 +20,11 @@ import unittest
from topydo.lib.Config import config
from topydo.lib.Recurrence import advance_recurring_todo, strict_advance_recurring_todo, NoRecurrenceException
from topydo.lib.Todo import Todo
import TopydoTest
class RecurrenceTest(unittest.TestCase):
class RecurrenceTest(TopydoTest.TopydoTest):
def setUp(self):
super(RecurrenceTest, self).setUp()
self.todo = Todo("Test rec:1w")
def test_duedate1(self):
......
......@@ -18,9 +18,11 @@ from datetime import date, timedelta
import unittest
from topydo.lib.RelativeDate import relative_date_to_date
import TopydoTest
class RelativeDateTester(unittest.TestCase):
class RelativeDateTester(TopydoTest.TopydoTest):
def setUp(self):
super(RelativeDateTester, self).setUp()
self.today = date.today()
self.tomorrow = self.today + timedelta(1)
......
......@@ -20,9 +20,10 @@ from topydo.lib.Config import config
from topydo.lib.Sorter import Sorter
from TestFacilities import load_file, todolist_to_string, load_file_to_todolist
import TopydoTest
class SorterTest(unittest.TestCase):
def sort_file(self,p_filename, p_filename_ref, p_sorter):
class SorterTest(TopydoTest.TopydoTest):
def sort_file(self, p_filename, p_filename_ref, p_sorter):
"""
Sorts a file and compares it with a reference result.
Also check that the sort algorithm hasn't touched the original data.
......
......@@ -21,8 +21,9 @@ import re
import unittest
from topydo.lib.TodoBase import TodoBase
import TopydoTest
class TodoBaseTester(unittest.TestCase):
class TodoBaseTester(TopydoTest.TopydoTest):
def test_parse_tag(self):
todo = TodoBase("(C) Test foo:bar foo:baz foo_:baz_ blah:zah:haz")
......
......@@ -17,8 +17,9 @@
import unittest
from TestFacilities import load_file
import TopydoTest
class TodoFileTest(unittest.TestCase):
class TodoFileTest(TopydoTest.TopydoTest):
def test_empty_file(self):
todofile = load_file('test/data/TodoFileTest1.txt')
......
......@@ -24,9 +24,12 @@ from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.TodoList import TodoList
import TopydoTest
class TodoListTester(unittest.TestCase):
class TodoListTester(TopydoTest.TopydoTest):
def setUp(self):
super(TodoListTester, self).setUp()
self.todofile = TodoFile('test/data/TodoListTest.txt')
lines = [line for line in self.todofile.read() \
if re.search(r'\S', line)]
......@@ -209,8 +212,10 @@ class TodoListTester(unittest.TestCase):
self.todolist.set_priority(todo, 'B')
self.assertEquals(self.todolist.todo('6iu').source(), "(B) Foo @Context2 Not@Context +Project1 Not+Project")
class TodoListDependencyTester(unittest.TestCase):
class TodoListDependencyTester(TopydoTest.TopydoTest):
def setUp(self):
super(TodoListDependencyTester, self).setUp()
self.todolist = TodoList([])
self.todolist.add("Foo id:1")
self.todolist.add("Bar p:1")
......@@ -306,8 +311,10 @@ class TodoListDependencyTester(unittest.TestCase):
self.assertEqual(todo1.source(), 'Foo id:1')
self.assertEqual(todo2.source(), 'Bar p:1')
class TodoListCleanDependencyTester(unittest.TestCase):
class TodoListCleanDependencyTester(TopydoTest.TopydoTest):
def setUp(self):
super(TodoListCleanDependencyTester, self).setUp()
self.todolist = TodoList([])
self.todolist.add("Bar p:1")
self.todolist.add("Baz p:1 id:2")
......
......@@ -18,6 +18,7 @@ from datetime import date, timedelta
import unittest
from topydo.lib.Todo import Todo
import TopydoTest
def today_date():
today = date.today()
......@@ -27,7 +28,7 @@ def tomorrow_date():
tomorrow = date.today() + timedelta(days=1)
return tomorrow.isoformat()
class TodoTest(unittest.TestCase):
class TodoTest(TopydoTest.TopydoTest):
def test_due_date1(self):
todo = Todo("(C) Foo due:2014-06-09")
due = date(2014, 6, 9)
......
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from topydo.lib.Config import config
class TopydoTest(unittest.TestCase):
def setUp(self):
"""
Make sure that every test case starts with a clean configuration.
"""
config("")
......@@ -21,8 +21,9 @@ from topydo.lib.Sorter import Sorter
from TestFacilities import load_file, todolist_to_string
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList
import TopydoTest
class ViewTest(unittest.TestCase):
class ViewTest(TopydoTest.TopydoTest):
def test_view(self):
""" Check filters and printer for views. """
todofile = TodoFile('test/data/FilterTest1.txt')
......
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