1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[4.1.x] Fixed #34088 -- Fixed Sitemap.get_latest_lastmod() crash with empty items.

Bug in 480191244d.

Thanks Michal Čihař for the report.

Backport of 5eab4d1924 from main
This commit is contained in:
Daniel Ivanov
2022-11-04 16:43:40 +03:00
committed by Mariusz Felisiak
parent 84a2b2e7a7
commit eca526eab0
4 changed files with 35 additions and 1 deletions

View File

@@ -507,6 +507,16 @@ class HTTPSitemapTests(SitemapTestsBase):
self.assertXMLEqual(index_response.content.decode(), expected_content_index)
self.assertXMLEqual(sitemap_response.content.decode(), expected_content_sitemap)
def test_callable_sitemod_no_items(self):
index_response = self.client.get("/callable-lastmod-no-items/index.xml")
self.assertNotIn("Last-Modified", index_response)
expected_content_index = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>http://example.com/simple/sitemap-callable-lastmod.xml</loc></sitemap>
</sitemapindex>
"""
self.assertXMLEqual(index_response.content.decode(), expected_content_index)
# RemovedInDjango50Warning
class DeprecatedTests(SitemapTestsBase):