kopia lustrzana https://github.com/collective/icalendar
Fix tests for latest pytz. Don't set tzinfo directly on datetime objects, but use pytz's localize function.
rodzic
c6b86de2d9
commit
605f1c2265
|
@ -5,8 +5,12 @@ Changelog
|
|||
3.6.3 (unreleased)
|
||||
------------------
|
||||
|
||||
- Remove incorrect use of __all__. We don't encourage using `from package
|
||||
import *` imports. Fixes #129.
|
||||
- Fix tests for latest ``pytz``. Don't set ``tzinfo`` directly on datetime
|
||||
objects, but use pytz's ``localize`` function.
|
||||
[untitaker, thet]
|
||||
|
||||
- Remove incorrect use of __all__. We don't encourage using ``from package
|
||||
import *`` imports. Fixes #129.
|
||||
[eric-wieser]
|
||||
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ class vDatetime(object):
|
|||
elif not ical[15:]:
|
||||
return datetime(*timetuple)
|
||||
elif ical[15:16] == 'Z':
|
||||
return datetime(tzinfo=pytz.utc, *timetuple)
|
||||
return pytz.utc.localize(datetime(*timetuple))
|
||||
else:
|
||||
raise ValueError(ical)
|
||||
except:
|
||||
|
|
|
@ -41,15 +41,15 @@ class TestEncoding(unittest.TestCase):
|
|||
event = icalendar.Event()
|
||||
event.add(
|
||||
'dtstart',
|
||||
datetime.datetime(2010, 10, 10, 10, 00, 00, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(2010, 10, 10, 10, 0, 0))
|
||||
)
|
||||
event.add(
|
||||
'dtend',
|
||||
datetime.datetime(2010, 10, 10, 12, 00, 00, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(2010, 10, 10, 12, 0, 0))
|
||||
)
|
||||
event.add(
|
||||
'created',
|
||||
datetime.datetime(2010, 10, 10, 0, 0, 0, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(2010, 10, 10, 0, 0, 0))
|
||||
)
|
||||
event.add('uid', u'123456')
|
||||
event.add('summary', u'Non-ASCII Test: ÄÖÜ äöü €')
|
||||
|
@ -68,7 +68,7 @@ class TestEncoding(unittest.TestCase):
|
|||
event = icalendar.Event()
|
||||
event.add(
|
||||
"dtstart",
|
||||
datetime.datetime(2010, 10, 10, 0, 0, 0, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(2010, 10, 10, 0, 0, 0))
|
||||
)
|
||||
event.add("summary", u"åäö")
|
||||
out = event.to_ical()
|
||||
|
|
|
@ -31,17 +31,17 @@ class TestRecurrence(unittest.TestCase):
|
|||
|
||||
self.assertEqual(
|
||||
first_event['exdate'].dts[0].dt,
|
||||
datetime.datetime(1996, 4, 2, 1, 0, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(1996, 4, 2, 1, 0))
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
first_event['exdate'].dts[1].dt,
|
||||
datetime.datetime(1996, 4, 3, 1, 0, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(1996, 4, 3, 1, 0))
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
first_event['exdate'].dts[2].dt,
|
||||
datetime.datetime(1996, 4, 4, 1, 0, tzinfo=pytz.utc)
|
||||
pytz.utc.localize(datetime.datetime(1996, 4, 4, 1, 0))
|
||||
)
|
||||
|
||||
def test_recurrence_exdates_multiple_lines(self):
|
||||
|
|
|
@ -42,7 +42,10 @@ class TestTimezoned(unittest.TestCase):
|
|||
)
|
||||
self.assertEqual(
|
||||
ev1.decoded('DTSTAMP'),
|
||||
datetime.datetime(2010, 10, 10, 9, 10, 10, tzinfo=pytz.utc))
|
||||
pytz.utc.localize(
|
||||
datetime.datetime(2010, 10, 10, 9, 10, 10)
|
||||
)
|
||||
)
|
||||
|
||||
def test_create_to_ical(self):
|
||||
cal = icalendar.Calendar()
|
||||
|
|
|
@ -216,8 +216,8 @@ class TestCalComponent(unittest.TestCase):
|
|||
comp.add('dtstart', vienna.localize(datetime(2010, 10, 10, 10, 0, 0)))
|
||||
comp.add('created', datetime(2010, 10, 10, 12, 0, 0))
|
||||
comp.add('dtstamp', vienna.localize(datetime(2010, 10, 10, 14, 0, 0)))
|
||||
comp.add('last-modified', datetime(2010, 10, 10, 16, 0, 0,
|
||||
tzinfo=pytz.utc))
|
||||
comp.add('last-modified', pytz.utc.localize(
|
||||
datetime(2010, 10, 10, 16, 0, 0)))
|
||||
|
||||
lines = comp.to_ical().splitlines()
|
||||
self.assertTrue(
|
||||
|
|
|
@ -100,7 +100,7 @@ class TestProp(unittest.TestCase):
|
|||
datetime))
|
||||
|
||||
self.assertEqual(vDDDTypes.from_ical('20010101T123000Z'),
|
||||
datetime(2001, 1, 1, 12, 30, tzinfo=pytz.utc))
|
||||
pytz.utc.localize(datetime(2001, 1, 1, 12, 30)))
|
||||
|
||||
self.assertTrue(isinstance(vDDDTypes.from_ical('20010101'), date))
|
||||
|
||||
|
@ -130,10 +130,10 @@ class TestProp(unittest.TestCase):
|
|||
self.assertEqual(vDatetime.from_ical('20000101T120000'),
|
||||
datetime(2000, 1, 1, 12, 0))
|
||||
|
||||
dutc = datetime(2001, 1, 1, 12, 30, 0, tzinfo=pytz.utc)
|
||||
dutc = pytz.utc.localize(datetime(2001, 1, 1, 12, 30, 0))
|
||||
self.assertEqual(vDatetime(dutc).to_ical(), b'20010101T123000Z')
|
||||
|
||||
dutc = datetime(1899, 1, 1, 12, 30, 0, tzinfo=pytz.utc)
|
||||
dutc = pytz.utc.localize(datetime(1899, 1, 1, 12, 30, 0))
|
||||
self.assertEqual(vDatetime(dutc).to_ical(), b'18990101T123000Z')
|
||||
|
||||
self.assertEqual(vDatetime.from_ical('20010101T000000'),
|
||||
|
|
Ładowanie…
Reference in New Issue