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
pull/113/head
Christian Geier 2013-10-24 02:39:18 +02:00
rodzic 11c8e9d72d
commit 25e54f19bd
4 zmienionych plików z 16 dodań i 19 usunięć

Wyświetl plik

@ -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?)

Wyświetl plik

@ -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"
)

Wyświetl plik

@ -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(

Wyświetl plik

@ -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'
)