kopia lustrzana https://github.com/collective/icalendar
commit
508fbdb317
3
setup.py
3
setup.py
|
@ -21,6 +21,9 @@ tests_require = []
|
|||
install_requires = [
|
||||
'python-dateutil',
|
||||
'pytz',
|
||||
# install requirements depending on python version
|
||||
# see https://www.python.org/dev/peps/pep-0508/#environment-markers
|
||||
'backports.zoneinfo; python_version == "3.7" or python_version == "3.8"',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,13 @@ import datetime
|
|||
import icalendar
|
||||
import os
|
||||
import pytz
|
||||
import pytest
|
||||
from dateutil import tz
|
||||
|
||||
try:
|
||||
import zoneinfo
|
||||
except ModuleNotFoundError:
|
||||
from backports import zoneinfo
|
||||
|
||||
class TestIssues(unittest.TestCase):
|
||||
|
||||
|
@ -487,4 +493,15 @@ END:VCALENDAR"""
|
|||
self.assertEqual(uid2.split('@')[1], 'test.test')
|
||||
self.assertEqual(uid3.split('-')[1], '123@example.com')
|
||||
self.assertEqual(uid4.split('-')[1], '123@test.test')
|
||||
|
||||
|
||||
@pytest.mark.parametrize("zone", [
|
||||
pytz.utc,
|
||||
zoneinfo.ZoneInfo('UTC'),
|
||||
pytz.timezone('UTC'),
|
||||
tz.UTC,
|
||||
tz.gettz('UTC')])
|
||||
def test_issue_335_identify_UTC(zone):
|
||||
myevent = icalendar.Event()
|
||||
dt = datetime.datetime(2021, 11, 17, 15, 9, 15)
|
||||
myevent.add('dtstart', dt.astimezone(zone))
|
||||
assert 'DTSTART;VALUE=DATE-TIME:20211117T150915Z' in myevent.to_ical().decode('ASCII')
|
||||
|
|
|
@ -8,17 +8,11 @@ import pytz
|
|||
try:
|
||||
import zoneinfo
|
||||
except:
|
||||
try:
|
||||
from backports import zoneinfo
|
||||
except:
|
||||
zoneinfo = None
|
||||
from backports import zoneinfo
|
||||
|
||||
class TestTimezoned(unittest.TestCase):
|
||||
|
||||
def test_create_from_ical_zoneinfo(self):
|
||||
if zoneinfo is None:
|
||||
self.skipTest("zoneinfo library not found for this python version")
|
||||
|
||||
directory = os.path.dirname(__file__)
|
||||
with open(os.path.join(directory, 'timezoned.ics'), 'rb') as fp:
|
||||
data = fp.read()
|
||||
|
@ -172,9 +166,6 @@ class TestTimezoned(unittest.TestCase):
|
|||
self.assertTrue("CREATED;VALUE=DATE-TIME:20101010T081010Z" in test_out)
|
||||
|
||||
def test_create_to_ical_zoneinfo(self):
|
||||
if zoneinfo is None:
|
||||
self.skipTest("zoneinfo library not found for this python version")
|
||||
|
||||
cal = icalendar.Calendar()
|
||||
|
||||
cal.add('prodid', "-//Plone.org//NONSGML plone.app.event//EN")
|
||||
|
|
Ładowanie…
Reference in New Issue