#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 , 14 years ago
Keywords: | blocker added |
---|---|
milestone: | → 1.3 |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.