Commit 496e0339 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge branch 'master' of github.com:bram85/topydo

parents bac98294 d7e034dc
...@@ -21,11 +21,19 @@ import unittest ...@@ -21,11 +21,19 @@ import unittest
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.commands.IcalCommand import IcalCommand from topydo.commands.IcalCommand import IcalCommand
from test.CommandTest import CommandTest from test.CommandTest import CommandTest, utf8
from test.TestFacilities import load_file_to_todolist from test.TestFacilities import load_file_to_todolist
IS_PYTHON_32 = (sys.version_info.major, sys.version_info.minor) == (3, 2) IS_PYTHON_32 = (sys.version_info.major, sys.version_info.minor) == (3, 2)
def replace_ical_tags(p_text):
# replace identifiers with dots, since they're random.
result = re.sub(r'\bical:....\b', 'ical:....', p_text)
result = re.sub(r'\bUID:....\b', 'UID:....', result)
return result
class IcalCommandTest(CommandTest): class IcalCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(IcalCommandTest, self).setUp() super(IcalCommandTest, self).setUp()
...@@ -33,13 +41,6 @@ class IcalCommandTest(CommandTest): ...@@ -33,13 +41,6 @@ class IcalCommandTest(CommandTest):
@unittest.skipIf(IS_PYTHON_32, "icalendar is not supported for Python 3.2") @unittest.skipIf(IS_PYTHON_32, "icalendar is not supported for Python 3.2")
def test_ical(self): def test_ical(self):
def replace_ical_tags(p_text):
# replace identifiers with dots, since they're random.
result = re.sub(r'\bical:....\b', 'ical:....', p_text)
result = re.sub(r'\bUID:....\b', 'UID:....', result)
return result
command = IcalCommand([""], self.todolist, self.out, self.error) command = IcalCommand([""], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -80,5 +81,24 @@ class IcalCommandTest(CommandTest): ...@@ -80,5 +81,24 @@ class IcalCommandTest(CommandTest):
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, "icalendar is not supported in this Python version.\n") self.assertEqual(self.errors, "icalendar is not supported in this Python version.\n")
class IcalCommandUnicodeTest(CommandTest):
def setUp(self):
super(IcalCommandUnicodeTest, self).setUp()
self.todolist = load_file_to_todolist("test/data/ListCommandUnicodeTest.txt")
@unittest.skipIf(IS_PYTHON_32, "icalendar is not supported for Python 3.2")
def test_ical_unicode(self):
command = IcalCommand([""], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
icaltext = ""
with codecs.open('test/data/ListCommandUnicodeTest.ics', 'r', encoding='utf-8') as ical:
icaltext = ical.read()
self.assertEqual(replace_ical_tags(self.output), utf8(replace_ical_tags(icaltext)))
self.assertEqual(self.errors, "")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff was suppressed by a .gitattributes entry.
...@@ -16,12 +16,15 @@ ...@@ -16,12 +16,15 @@
""" A view is a list of todos, sorted and filtered. """ """ A view is a list of todos, sorted and filtered. """
from six import python_2_unicode_compatible
from topydo.lib.PrettyPrinterFilter import ( from topydo.lib.PrettyPrinterFilter import (
PrettyPrinterColorFilter, PrettyPrinterColorFilter,
PrettyPrinterNumbers PrettyPrinterNumbers
) )
from topydo.lib.PrettyPrinter import PrettyPrinter from topydo.lib.PrettyPrinter import PrettyPrinter
@python_2_unicode_compatible
class View(object): class View(object):
""" """
A view is instantiated by a todo list, usually obtained from a todo.txt A view is instantiated by a todo list, usually obtained from a todo.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