Commit 97407782 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Properly handle Python 3.2 where icalendar is not supported.

parent f7243582
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
import codecs import codecs
import re import re
import sys
import unittest import unittest
from topydo.lib.Config import config
from test.CommandTest import CommandTest from test.CommandTest import CommandTest
from topydo.lib.IcalCommand import IcalCommand from topydo.lib.IcalCommand import IcalCommand
from test.TestFacilities import load_file_to_todolist from test.TestFacilities import load_file_to_todolist
...@@ -28,6 +28,7 @@ class IcalCommandTest(CommandTest): ...@@ -28,6 +28,7 @@ class IcalCommandTest(CommandTest):
super(IcalCommandTest, self).setUp() super(IcalCommandTest, self).setUp()
self.todolist = load_file_to_todolist("test/data/ListCommandTest.txt") self.todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
@unittest.skipIf((sys.version_info.major, sys.version_info.minor) == (3, 2), "icalendar is not supported for Python 3.2")
def test_ical(self): def test_ical(self):
def replace_ical_tags(p_text): def replace_ical_tags(p_text):
# replace identifiers with dots, since they're random. # replace identifiers with dots, since they're random.
...@@ -48,6 +49,18 @@ class IcalCommandTest(CommandTest): ...@@ -48,6 +49,18 @@ class IcalCommandTest(CommandTest):
self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext)) self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext))
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@unittest.skipUnless((sys.version_info.major, sys.version_info.minor) == (3,2), "icalendar is not supported for Python 3.2")
def test_ical_python32(self):
"""
Test case for Python 3.2 where icalendar is not supported.
"""
command = IcalCommand([""], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, '')
self.assertEqual(self.errors, "icalendar is not supported in this Python version.\n")
def test_help(self): def test_help(self):
command = IcalCommand(["help"], self.todolist, self.out, self.error) command = IcalCommand(["help"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -40,6 +40,9 @@ class IcalCommand(ListCommand): ...@@ -40,6 +40,9 @@ class IcalCommand(ListCommand):
except ImportError: except ImportError:
self.error("icalendar package is not installed.") self.error("icalendar package is not installed.")
return False return False
except SyntaxError:
self.error("icalendar is not supported in this Python version.")
return False
return super(IcalCommand, self).execute() return super(IcalCommand, self).execute()
......
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