From b0139dad8d2e37d0910cf4566709b2c153c6cda9 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Thu, 24 Apr 2025 14:03:47 +0200 Subject: [PATCH] Fixed atom feed encoding to utf-8 --- CHANGELOG.md | 1 + blag/blag.py | 2 +- tests/test_blag.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84eb38c..3ec3dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [unreleased] +* Fixed Atom feed encoding to 'utf-8' * Added Python 3.13 to github actions * `requirements*.txt` files are handled by pip-tools. Updates are handled by make update-requirements based on the dependencies described in the diff --git a/blag/blag.py b/blag/blag.py index ed6db15..99b70e2 100644 --- a/blag/blag.py +++ b/blag/blag.py @@ -396,7 +396,7 @@ def generate_feed( ) with open(f"{output_dir}/atom.xml", "w") as fh: - feed.write(fh, encoding="utf8") + feed.write(fh, encoding='utf-8') def generate_index( diff --git a/tests/test_blag.py b/tests/test_blag.py index c7d1ca8..9311b39 100644 --- a/tests/test_blag.py +++ b/tests/test_blag.py @@ -99,6 +99,15 @@ def test_generate_feed_with_description(cleandir: str) -> None: assert 'content' in feed +def test_feed_is_unicode(cleandir: str) -> None: + """Test generate_feed.""" + articles: list[tuple[str, dict[str, Any]]] = [] + blag.generate_feed(articles, "build", " ", " ", " ", " ") + with open("build/atom.xml") as fh: + feed = fh.read() + assert 'encoding="utf-8"' in feed + + def test_parse_args_build() -> None: """Test parse_args with build.""" # test default args