Opened 18 years ago

Closed 16 years ago

#2099 closed defect (fixed)

dateformat test fails on Windows (Python 2.4.2)

Reported by: a.lebedev@… Owned by: Adrian Holovaty
Component: Testing framework Version: dev
Severity: normal Keywords: windows timezone
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When trying to run unit test suite against sqlite3 database you get one test failing:

D:\doc\study\django\alex>d:\django\tests\runtests  --settings=settings
Running tests with database 'sqlite3'

'dateformat' module: Error while importing
==========================================
  File "d:\django\tests\runtests.py", line 208, in run_tests
    mod = __import__("othertests." + module, '', '', [''])
  File "d:\django\tests\othertests\dateformat.py", line 76, in ?
    time.tzset()
AttributeError: 'module' object has no attribute 'tzset'

1 error:

Always reproduces. Using latest SVN (3091)

Environment:
Pyhton 2.4.2
Windows XP SP2

Attachments (1)

dateformat_win32.patch (1.8 KB ) - added by Chris Beaven 18 years ago.
fix so windows users can still run test suite

Download all attachments as: .zip

Change History (8)

comment:1 by Chris Beaven, 18 years ago

Just to be clear, it's not a database problem, it's the fact that .tzset() is only available in unix.

comment:2 by Chris Beaven, 18 years ago

... and from my research, it's not coming to Win32 any time soon. I'm not sure what the solution is here. Perhaps just ignoring Win32 and splitting all the timezone dependant tests to a seperate module that only runs if tzset is available?

pytz - World Time Definitions for Python is a great library for using proper tzinfo objects rather than just changing the local timezone for Python, but I doubt Django developers want any more dependancies.

comment:3 by asmodai@…, 18 years ago

Given this thread I doubt you will get any decent tzset() working natively by Python.

Stuart Bishop, the guy of the pytz package, is actually one of the participants of that tzset() discussion.

Even on POSIX things are not standardised when it comes to the environment variable TZ.

by Chris Beaven, 18 years ago

Attachment: dateformat_win32.patch added

fix so windows users can still run test suite

comment:4 by Malcolm Tredinnick, 18 years ago

This looks good, although the tests should be in the opposite order (no_tz or ...) so that short-circuiting mean we bail out even attempting the path that is known to fail. Slightly better programming practice that way (more efficient in other circumstances, too). Dont' worry about making another patch, though. I'll apply this later this morning and fix it then.

comment:5 by mir@…, 18 years ago

Has patch: set
Keywords: windows timezone added
Resolution: fixed
Status: newclosed

looks like this patch has already been applied.

comment:7 by James Bennett, 16 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top