Fixed #26653 -- Made SyndicationFeed.latest_post_date() return time in UTC.

This commit is contained in:
Ketan Bhatt 2016-05-24 22:20:20 +05:30 committed by Tim Graham
parent 92107522ed
commit f31fbbae1a
4 changed files with 24 additions and 7 deletions

View file

@ -1,13 +1,13 @@
from __future__ import unicode_literals
import datetime
import unittest
from django.test import SimpleTestCase
from django.utils import feedgenerator
from django.utils.timezone import get_fixed_timezone
from django.utils.timezone import get_fixed_timezone, utc
class FeedgeneratorTest(unittest.TestCase):
class FeedgeneratorTest(SimpleTestCase):
"""
Tests for the low-level syndication feed framework.
"""
@ -121,3 +121,9 @@ class FeedgeneratorTest(unittest.TestCase):
self.assertIn('<atom:link', feed_content)
self.assertIn('href="/feed/"', feed_content)
self.assertIn('rel="self"', feed_content)
def test_latest_post_date_returns_utc_time(self):
for use_tz in (True, False):
with self.settings(USE_TZ=use_tz):
rss_feed = feedgenerator.Rss201rev2Feed('title', 'link', 'description')
self.assertEqual(rss_feed.latest_post_date().tzinfo, utc)