From 25e54f19bdcabb9e6ac2959d6109cdd4a237ef0a Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Thu, 24 Oct 2013 02:39:18 +0200 Subject: [PATCH] more bytestrings this time there was the need to change some tests from str(caselessdict) == CaselessDict"{u'foo': u'bar'}" to assert isinstance(caselessdict, CaselessDict) caselessdict == {u'foo': u'bar'} down to 2 and a half (one is wobbly) failed tests in python3.3 --- src/icalendar/PYTHON3_TODO.txt | 7 ------- src/icalendar/tests/test_fixed_issues.py | 6 +++--- src/icalendar/tests/test_recurrence.py | 7 ++++--- src/icalendar/tests/test_unit_prop.py | 15 +++++++++------ 4 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 src/icalendar/PYTHON3_TODO.txt diff --git a/src/icalendar/PYTHON3_TODO.txt b/src/icalendar/PYTHON3_TODO.txt deleted file mode 100644 index 4ef8409..0000000 --- a/src/icalendar/PYTHON3_TODO.txt +++ /dev/null @@ -1,7 +0,0 @@ -* several errors in Caseless dict's to_ical() - TypeError: sequence item 0: expected bytes, str found -* data_encode should return strings vom dicts without enclosed 'b's - (this is the main source of failed tests at the moment) -* base64 encoding needs to be redone -=============================================================== -* should to_ical() not better return unicode? (not bytes?) diff --git a/src/icalendar/tests/test_fixed_issues.py b/src/icalendar/tests/test_fixed_issues.py index 0fb0f92..d41c367 100644 --- a/src/icalendar/tests/test_fixed_issues.py +++ b/src/icalendar/tests/test_fixed_issues.py @@ -124,12 +124,12 @@ END:VEVENT""" b = icalendar.vBinary('text') b.params['FMTTYPE'] = 'text/plain' - self.assertEqual(b.to_ical(), 'dGV4dA==') + self.assertEqual(b.to_ical(), b'dGV4dA==') e = icalendar.Event() e.add('ATTACH', b) self.assertEqual(e.to_ical(), - "BEGIN:VEVENT\r\nATTACH;ENCODING=BASE64;FMTTYPE=text/plain;" - "VALUE=BINARY:dGV4dA==\r\nEND:VEVENT\r\n" + b"BEGIN:VEVENT\r\nATTACH;ENCODING=BASE64;FMTTYPE=text/plain;" + b"VALUE=BINARY:dGV4dA==\r\nEND:VEVENT\r\n" ) diff --git a/src/icalendar/tests/test_recurrence.py b/src/icalendar/tests/test_recurrence.py index 902eaa9..1596d09 100644 --- a/src/icalendar/tests/test_recurrence.py +++ b/src/icalendar/tests/test_recurrence.py @@ -6,6 +6,7 @@ import dateutil.parser import os from . import unittest +from icalendar.caselessdict import CaselessDict class TestRecurrence(unittest.TestCase): @@ -19,14 +20,14 @@ class TestRecurrence(unittest.TestCase): def test_recurrence_exdates_one_line(self): first_event = self.cal.walk('vevent')[0] + self.assertIsInstance(first_event, CaselessDict) self.assertEqual( - str(first_event['rrule']), - "CaselessDict({'COUNT': [100], 'FREQ': ['DAILY']})" + first_event['rrule'], {'COUNT': [100], 'FREQ': ['DAILY']} ) self.assertEqual( first_event['exdate'].to_ical(), - '19960402T010000Z,19960403T010000Z,19960404T010000Z' + b'19960402T010000Z,19960403T010000Z,19960404T010000Z' ) self.assertEqual( diff --git a/src/icalendar/tests/test_unit_prop.py b/src/icalendar/tests/test_unit_prop.py index beae199..077bffc 100644 --- a/src/icalendar/tests/test_unit_prop.py +++ b/src/icalendar/tests/test_unit_prop.py @@ -1,5 +1,8 @@ +# -*- coding: utf-8 -*- from datetime import datetime, date, timedelta, time from . import unittest +from icalendar.parser import Parameters + import pytz @@ -48,7 +51,8 @@ class TestProp(unittest.TestCase): a.params['cn'] = 'Max M' self.assertEqual(a.to_ical(), txt) - self.assertEqual(str(a.params), "Parameters({'CN': 'Max M'})") + self.assertIsInstance(a.params, Parameters) + self.assertEqual(a.params, {'CN': 'Max M'}) self.assertEqual(vCalAddress.from_ical(txt), 'MAILTO:maxm@mxm.dk') def test_prop_vFloat(self): @@ -430,8 +434,8 @@ class TestProp(unittest.TestCase): t2 = vInline('other text') t2.params['cn'] = 'Test Osterone' - self.assertEqual(str(t2.params), - "Parameters({'CN': 'Test Osterone'})") + self.assertIsInstance(t2.params, Parameters) + self.assertEqual(t2.params, {'CN': 'Test Osterone'}) def test_prop_TypesFactory(self): from ..prop import TypesFactory @@ -456,10 +460,9 @@ class TestProp(unittest.TestCase): ) self.assertEqual(factory.to_ical('priority', 1), b'1') self.assertEqual(factory.to_ical('cn', u'Rasmussen, Max M\xfcller'), - 'Rasmussen\\, Max M\xc3\xbcller') - + b'Rasmussen\\, Max M\xc3\xbcller') self.assertEqual( - factory.from_ical('cn', 'Rasmussen\\, Max M\xc3\xb8ller'), + factory.from_ical('cn', b'Rasmussen\\, Max M\xc3\xb8ller'), u'Rasmussen, Max M\xf8ller' )