Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpin pytest #88

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
]

[project.optional-dependencies]
test = ["pytest == 7.4.4", "pytest-cov == 4.1.0"]
test = ["pytest >= 7.4.4", "pytest-cov >= 4.1.0"]
lint = ["pre-commit == 3.6.0"]
dev = ["changelist == 0.4"]

Expand Down
Empty file added tests/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions tests/test_events.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from util import parse_yaml

from yaml2ics import event_from_yaml

from .util import parse_yaml


def test_basic_structure():
event = event_from_yaml(
Expand Down
10 changes: 9 additions & 1 deletion yaml2ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def datetime2utc(date):
return datetime.datetime.strftime(date, "%Y%m%d")


def utcnow():
try:
return datetime.datetime.now(datetime.UTC).replace(tzinfo=dateutil.tz.UTC)
except AttributeError:
# This section can be removed once Python 3.11 is the minimum version
jarrodmillman marked this conversation as resolved.
Show resolved Hide resolved
return datetime.datetime.utcnow().replace(tzinfo=dateutil.tz.UTC)


# See RFC2445, 4.8.5 REcurrence Component Properties
# This function can be used to add a list of e.g. exception dates (EXDATE) or
# recurrence dates (RDATE) to a reoccurring event
Expand Down Expand Up @@ -120,7 +128,7 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event:
rdates = [datetime2utc(rdate) for rdate in repeat["also_on"]]
add_recurrence_property(event, "RDATE", rdates, tz)

event.dtstamp = datetime.datetime.utcnow().replace(tzinfo=dateutil.tz.UTC)
event.dtstamp = utcnow()
if tz and event.floating and not event.all_day:
event.replace_timezone(tz)

Expand Down
Loading