From 55bf82934b3d30e622e3a08f561f24b6ee973a35 Mon Sep 17 00:00:00 2001 From: Georges Toth Date: Tue, 19 Dec 2023 16:40:00 +0100 Subject: [PATCH] removed dependency on pytz; kept tzlocal only for testing; added backports.zoneinfo in case of ='3.9'", ] - if sys.version_info.major == 3 and sys.version_info.minor < 9: - test_packages.append("xandikos==0.2.8") - test_packages.append("dulwich==0.20.50") - else: - test_packages.append("xandikos") - setup( name="caldav", version=version, @@ -90,8 +71,7 @@ "icalendar", "recurring-ical-events>=2.0.0", "typing_extensions", - ] - + extra_packages, + ], extras_require={ "test": test_packages, }, diff --git a/tests/test_cdav.py b/tests/test_cdav.py index 417ef7f5..a6b3ee88 100644 --- a/tests/test_cdav.py +++ b/tests/test_cdav.py @@ -1,11 +1,15 @@ import datetime -import pytz import tzlocal from caldav.elements.cdav import _to_utc_date_string from caldav.elements.cdav import CalendarQuery -SOMEWHERE_REMOTE = pytz.timezone("Brazil/DeNoronha") # UTC-2 and no DST +try: + import zoneinfo +except ImportError: + from backports import zoneinfo + +SOMEWHERE_REMOTE = zoneinfo.ZoneInfo("Brazil/DeNoronha") # UTC-2 and no DST def test_element(): @@ -32,9 +36,9 @@ def test_to_utc_date_string_utc(): assert res == "20190514T211023Z" -def test_to_utc_date_string_dt_with_pytz_tzinfo(): - input = datetime.datetime(2019, 5, 14, 21, 10, 23, 23) - res = _to_utc_date_string(SOMEWHERE_REMOTE.localize(input)) +def test_to_utc_date_string_dt_with_zoneinfo_tzinfo(): + input = datetime.datetime(2019, 5, 14, 21, 10, 23, 23, tzinfo=SOMEWHERE_REMOTE) + res = _to_utc_date_string(input) assert res == "20190514T231023Z" diff --git a/tests/test_vcal.py b/tests/test_vcal.py index a0ba5d56..b5bc2470 100644 --- a/tests/test_vcal.py +++ b/tests/test_vcal.py @@ -3,11 +3,11 @@ import uuid from datetime import datetime from datetime import timedelta +from datetime import timezone from unittest import TestCase import icalendar import pytest -import pytz import vobject from caldav.lib import vcal from caldav.lib.python_utilities import to_normal_str @@ -15,9 +15,7 @@ from caldav.lib.vcal import create_ical from caldav.lib.vcal import fix -# from datetime import timezone -# utc = timezone.utc -utc = pytz.utc +utc = timezone.utc # example from http://www.rfc-editor.org/rfc/rfc5545.txt ev = """BEGIN:VCALENDAR