Django

Code

Ticket #2099 (closed: fixed)

Opened 2 years ago

Last modified 3 days ago

dateformat test fails on Windows (Python 2.4.2)

Reported by: a.lebedev@list.ru Assigned to: adrian
Milestone: Component: Testing framework
Version: SVN Keywords: windows timezone
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

dateformat_win32.patch (1.8 kB) - added by SmileyChris on 09/23/06 17:03:36.
fix so windows users can still run test suite

Change History

06/06/06 18:00:10 changed by SmileyChris

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

06/06/06 18:57:39 changed by SmileyChris

... 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.

06/07/06 04:59:02 changed by asmodai@in-nomine.org

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.

09/23/06 17:03:36 changed by SmileyChris

  • attachment dateformat_win32.patch added.

fix so windows users can still run test suite

09/23/06 18:55:29 changed by mtredinnick

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.

01/30/07 15:17:33 changed by mir@noris.de

  • keywords set to windows timezone.
  • status changed from new to closed.
  • has_patch set to 1.
  • resolution set to fixed.

looks like this patch has already been applied.

10/12/08 19:10:14 changed by ubernostrum

  • status changed from reopened to closed.
  • resolution set to fixed.

Add/Change #2099 (dateformat test fails on Windows (Python 2.4.2))




Change Properties
Action