Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15048 closed (fixed)

Test failing on Python 2.4 since year 2011 :)

Reported by: lrekucki Owned by: nobody
Component: Generic views Version: master
Severity: Keywords: blocker
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Test test "generic_views.WeekArchiveViewTests.test_week_view_allow_future" fails on Python 2.4.6 in year 2011. The code in question is "_date_from_string" which uses time.strptime() which is a bit broken in Python 2.4:

The failing test tries to list books in the 0th week of the next year. For the year 2012, Python 2.4 is a bit wrong about the date of the first Sunday:

# Python 2.4.6
>>> from time import strptime
>>> strptime("2012__0__0", "%Y__%w__%U")
(2011, 12, 25, 0, 0, 0, 6, -6, -1)

Well, 25th December 2011 is a Sunday, but the first Sunday of 2012 is 1st of January:

# Python 2.6.6
>>> from time import strptime
>>> strptime("2012__0__0", "%Y__%w__%U")
time.struct_time(tm_year=2012, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=1, tm_isdst=-1)

Generic views in Django 1.2 somehow don't seem affected by this.

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by russellm

  • Keywords blocker added
  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Method based generic views are affected -- they're just not tested as robustly as the new generic views.

Since this is a known failure in Python that has been fixed in subsequent releases, the fix probably lies in fixing the test suite to avoid the problematic date -- the test is just validating that a future date is rejected unless configured to be allowed, so if the test checks for week 1 rather than week 0, for example, the bug doesn't appear.

comment:2 Changed 3 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [15216]) Fixed #15048 -- Modified a test case to avoid a known bug in Python 2.4's time library. Thanks to Łukasz Rekucki for the report.

comment:3 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.