Skip to content

Commit 77f91fc

Browse files
Unpin pytest (#88)
* Work around pytest 8 failures xref: pytest-dev/pytest#9567 (comment) Also replaced `datetime.utcnow()` to avoid deprecation warning. * Unpin pytest and pytest-cov * Make utcnow compatible with Python <3.11 * Update yaml2ics.py --------- Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
1 parent 76dcd0c commit 77f91fc

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
]
2929

3030
[project.optional-dependencies]
31-
test = ["pytest == 7.4.4", "pytest-cov == 4.1.0"]
31+
test = ["pytest >= 7.4.4", "pytest-cov >= 4.1.0"]
3232
lint = ["pre-commit == 3.6.0"]
3333
dev = ["changelist == 0.4"]
3434

tests/__init__.py

Whitespace-only changes.

tests/test_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from util import parse_yaml
2-
31
from yaml2ics import event_from_yaml
42

3+
from .util import parse_yaml
4+
55

66
def test_basic_structure():
77
event = event_from_yaml(

yaml2ics.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ def datetime2utc(date):
3232
return datetime.datetime.strftime(date, "%Y%m%d")
3333

3434

35+
def utcnow():
36+
try:
37+
return datetime.datetime.now(datetime.UTC).replace(tzinfo=dateutil.tz.UTC)
38+
except AttributeError:
39+
# TODO: This section can be removed once Python 3.11 is the minimum version
40+
return datetime.datetime.utcnow().replace(tzinfo=dateutil.tz.UTC)
41+
42+
3543
# See RFC2445, 4.8.5 REcurrence Component Properties
3644
# This function can be used to add a list of e.g. exception dates (EXDATE) or
3745
# recurrence dates (RDATE) to a reoccurring event
@@ -120,7 +128,7 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event:
120128
rdates = [datetime2utc(rdate) for rdate in repeat["also_on"]]
121129
add_recurrence_property(event, "RDATE", rdates, tz)
122130

123-
event.dtstamp = datetime.datetime.utcnow().replace(tzinfo=dateutil.tz.UTC)
131+
event.dtstamp = utcnow()
124132
if tz and event.floating and not event.all_day:
125133
event.replace_timezone(tz)
126134

0 commit comments

Comments
 (0)