Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ permissions:

jobs:
test:
name: Test - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["pypy3.11", "3.9", "3.10", "3.11", "3.12", "3.13"]
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -15,7 +15,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = "~=3.9"
dependencies = []
dependencies = [
"tzdata; sys_platform == 'win32'",
]

[project.urls]
Homepage = "https://github.com/getpelican/feedgenerator"
Expand Down
29 changes: 28 additions & 1 deletion tests/test_feedgenerator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import datetime
from zoneinfo import ZoneInfo

import pytest

import feedgenerator

AWARE_DATE = datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("America/New_York"))
AWARE_DATE_UTC = datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("UTC"))
NAIVE_DATE = datetime.datetime(2016,8,11,0,0,0,0)

FIXT_FEED = dict(
title="Poynter E-Media Tidbits",
Expand All @@ -20,7 +24,7 @@
link="http://www.holovaty.com/täst/",
description="Testing.",
content="Full content of our testing entry.",
pubdate=datetime.datetime(2016,8,11,0,0,0,0),
pubdate=NAIVE_DATE,
)


Expand Down Expand Up @@ -135,3 +139,26 @@ def test_subtitle(description, subtitle, fragment, nonfragment):
assert fragment in result
if nonfragment:
assert nonfragment not in result

@pytest.mark.parametrize("generator, date, expected_date_string", [
(feedgenerator.Atom1Feed, AWARE_DATE, "2016-08-11T00:00:00-04:00"),
(feedgenerator.Atom1Feed, AWARE_DATE_UTC, "2016-08-11T00:00:00+00:00"),
(feedgenerator.Atom1Feed, NAIVE_DATE, "2016-08-11T00:00:00Z"),
(feedgenerator.Rss201rev2Feed, AWARE_DATE, "Thu, 11 Aug 2016 00:00:00 -0400"),
(feedgenerator.Rss201rev2Feed, AWARE_DATE_UTC, "Thu, 11 Aug 2016 00:00:00 +0000"),
(feedgenerator.Rss201rev2Feed, NAIVE_DATE, "Thu, 11 Aug 2016 00:00:00 -0000"),
(feedgenerator.RssUserland091Feed, AWARE_DATE, "Thu, 11 Aug 2016 00:00:00 -0400"),
(feedgenerator.RssUserland091Feed, AWARE_DATE_UTC, "Thu, 11 Aug 2016 00:00:00 +0000"),
(feedgenerator.RssUserland091Feed, NAIVE_DATE, "Thu, 11 Aug 2016 00:00:00 -0000"),
])
def test_timezone_handling(generator, date, expected_date_string):
"""
Test that dates are handled correctly in all Feed generators.
Also test special cases of no timezone given, vs timezone without offset
"""

feed = generator(**FIXT_FEED)
feed.add_item(**(FIXT_ITEM | {'pubdate': date}))
result = feed.writeString(ENCODING)

assert expected_date_string in result
Loading