Ticket #21165: fix_ticket_21165_syndication_last_modifed.patch

File fix_ticket_21165_syndication_last_modifed.patch, 2.2 KB (added by Raphaël Barrois, 11 years ago)

Patch to fix the tests on Windows

  • tests/syndication/tests.py

    diff --git a/tests/syndication/tests.py b/tests/syndication/tests.py
    index 1627f71..828de7a 100644
    a b  
    11from __future__ import absolute_import, unicode_literals
    22
     3import time
    34from xml.dom import minidom
    45
    56from django.contrib.syndication import views
    from django.core.exceptions import ImproperlyConfigured  
    78from django.test import TestCase
    89from django.utils import tzinfo
    910from django.utils.feedgenerator import rfc2822_date, rfc3339_date
     11from django.utils.unittest import skipUnless
    1012
    1113from .models import Entry
    1214
    1315
     16# Taken from tests/timezones/tests.py
     17TZ_SUPPORT = hasattr(time, 'tzset')
     18
     19# On OSes that don't provide tzset (Windows), we can't set the timezone
     20# in which the program runs. As a consequence, we must skip tests that
     21# don't enforce a specific timezone (with timezone.override or equivalent),
     22# or attempt to interpret naive datetimes in the default timezone.
     23
     24requires_tz_support = skipUnless(TZ_SUPPORT,
     25        "This test relies on the ability to run a program in an arbitrary "
     26        "time zone, but your operating system isn't able to do that.")
     27
     28
    1429class FeedTestCase(TestCase):
    1530    fixtures = ['feeddata.json']
    1631
    class SyndicationFeedTest(FeedTestCase):  
    260275        updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText
    261276        self.assertEqual(updated[-6:], '+00:42')
    262277
    263     def test_feed_last_modified_time(self):
     278    @requires_tz_support
     279    def test_feed_last_modified_time_naive_date(self):
     280        """
     281        Tests the Last-Modified header with naive publication dates
     282        """
    264283        response = self.client.get('/syndication/naive-dates/')
    265284        self.assertEqual(response['Last-Modified'], 'Thu, 03 Jan 2008 19:30:00 GMT')
    266285
     286    def test_feed_last_modified_time(self):
     287        response = self.client.get('/syndication/aware-dates/')
     288        self.assertEqual(response['Last-Modified'], 'Thu, 03 Jan 2008 12:48:00 GMT')
     289
    267290        # No last-modified when feed has no item_pubdate
    268291        response = self.client.get('/syndication/no_pubdate/')
    269292        self.assertFalse(response.has_header('Last-Modified'))
Back to Top