#27662: test suite fails in the last week of a leap year
------------------------------------------+------------------------
               Reporter:  Hartmut Goebel  |          Owner:  nobody
                   Type:  Bug             |         Status:  new
              Component:  Utilities       |        Version:  1.10
               Severity:  Normal          |       Keywords:
           Triage Stage:  Unreviewed      |      Has patch:  0
    Needs documentation:  0               |    Needs tests:  0
Patch needs improvement:  0               |  Easy pickings:  0
                  UI/UX:  0               |
------------------------------------------+------------------------
 When running the test suite in the last week of a leap year, some tests
 fail. This is due to a subtle bug in timesince().

 This bug **only** occurs if "now" is in a leap year and "d" (the date to
 be compared with now) is not. The test suite contains tests for comparing
 "now" with "now+oneweek", which is why this test fails only in the last
 week of a lead year.

 This test-case test for this bug. Just add it to
 "tests/utils_tests/test_timesince.py":
 {{{
     def test_year_boundry_current_is_leapyear(self):
         "Current year is a leap year, and next week is in next year"
         today = datetime.date(2016, 12, 28) # within the last week of a
 leap year
         self.assertEqual(timeuntil(today + self.oneweek, today),
 '1\xa0week')
 }}}

 "today" (2016) is in a leap year, while "today+oneweek" will be 2017-01-05
 which is not in a leap year.

 The bug is caused by django/utils/timesince.py, line 46:
 {{{
    delta -= datetime.timedelta(calendar.leapdays(d.year, now.year))
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27662>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.14df587890e046c3f65451033fc830b2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to