Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#15048 closed (fixed)

Test failing on Python 2.4 since year 2011 :)

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

Description

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: http://bugs.python.org/issue1643943

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.

Change History (3)

comment:1 by Russell Keith-Magee, 14 years ago

Keywords: blocker added
milestone: 1.3
Triage Stage: UnreviewedAccepted

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 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(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 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top