From: Rong Fu Date: Sun, 22 Mar 2026 22:08:39 +0100 Subject: Fix tests warnings for BeautifulSoup and timezone naive datetimes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit This patch adds the "tzinfo=timezone.utc" for datetime to make it as "aware datetime" in test_email.py This patch also fixes the warnings for BeautifulSoup with parameter "lxml" which uses the HTML parser mode of the lxml library, not the XML parser.• This is fine for parsing HTML documents, but when trying to parse an XML document, the parser may not handle certain XML-specific features properly, leading to the XMLParsedAsHTMLWarning. Forwarded: https://gitlab.com/mailman/hyperkitty/-/merge_requests/710 --- hyperkitty/tests/models/test_email.py | 10 +++++----- hyperkitty/tests/test_feeds.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) --- hyperkitty-1.3.12.orig/hyperkitty/tests/models/test_email.py +++ hyperkitty-1.3.12/hyperkitty/tests/models/test_email.py @@ -22,7 +22,7 @@ import os import tempfile -from datetime import datetime +from datetime import datetime, timezone from email import message_from_string from email.message import EmailMessage from mimetypes import guess_all_extensions @@ -186,11 +186,11 @@ class EmailTestCase(TestCase): def test_as_message_folded_subject(self): sender = Sender(address="dummy@example.com") mlist = MailingList(name="list@example.com") - email = Email(archived_date=datetime(2012, 11, 2, 12, 7, 54), + email = Email(archived_date=datetime(2012, 11, 2, 12, 7, 54, tzinfo=timezone.utc), timezone=0, message_id="msgid", sender=sender, - date=datetime(2012, 11, 2, 12, 7, 54), + date=datetime(2012, 11, 2, 12, 7, 54, tzinfo=timezone.utc), mailinglist=mlist, subject="This is a folded\n subject", in_reply_to="\n ", @@ -204,12 +204,12 @@ class EmailTestCase(TestCase): def test_as_message_specials_in_name(self): sender = Sender(address="dummy@example.com") mlist = MailingList(name="list@example.com") - email = Email(archived_date=datetime(2012, 11, 2, 12, 7, 54), + email = Email(archived_date=datetime(2012, 11, 2, 12, 7, 54, tzinfo=timezone.utc), timezone=0, message_id="msgid", sender=sender, sender_name="Team: J.Q. Doe", - date=datetime(2012, 11, 2, 12, 7, 54), + date=datetime(2012, 11, 2, 12, 7, 54, tzinfo=timezone.utc), mailinglist=mlist, subject="Message subject", content="Dummy message") --- hyperkitty-1.3.12.orig/hyperkitty/tests/test_feeds.py +++ hyperkitty-1.3.12/hyperkitty/tests/test_feeds.py @@ -50,7 +50,7 @@ class TestMailingListFeed(TestCase): url = reverse('hk_list_feed', args=('list@example.com', )) response = self.client.get(url) self.assertEqual(response.status_code, 200) - soup = BeautifulSoup(response.content, "lxml") + soup = BeautifulSoup(response.content, "lxml-xml") self.assertEqual(len(soup.find_all("title", string="First Subject")), 1) @@ -65,7 +65,7 @@ class TestMailingListFeed(TestCase): url = reverse('hk_list_feed', args=('list@example.com', )) response = self.client.get(url) self.assertEqual(response.status_code, 200) - soup = BeautifulSoup(response.content, "lxml") + soup = BeautifulSoup(response.content, "lxml-xml") self.assertEqual(len(soup.find_all("title", string="First Subject")), 1)