Opened 11 years ago

Closed 11 years ago

#21161 closed Bug (fixed)

Windows doesn't have tzset, regression added with d9413d33b2a8371731a92289123683cf6f440290

Reported by: Michael Manfre Owned by: anonymous
Component: Utilities Version: dev
Severity: Release blocker Keywords: timezones pytz
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Changeset d9413d33b2a8371731a92289123683cf6f440290 breaks a few tests on Windows using sqlite with pytz installed. Tests do not fail without pytz.

======================================================================
FAIL: test_templates (template_tests.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\django\django\tests\template_tests\tests.py", line 621, in test_templates
    ('-'*70, ("\n%s\n" % ('-'*70)).join(failures)))
AssertionError: Tests failed:
----------------------------------------------------------------------
Template test (Cached='False', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=False): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
Template test (Cached='True', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=False): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
Template test (Cached='False', TEMPLATE_STRING_IF_INVALID='INVALID', TEMPLATE_DEBUG=False): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
Template test (Cached='True', TEMPLATE_STRING_IF_INVALID='INVALID', TEMPLATE_DEBUG=False): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
Template test (Cached='False', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=True): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
Template test (Cached='True', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=True): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
 
======================================================================
FAIL: test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFormatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\django\django\tests\utils_tests\test_dateformat.py", line 39, in test_datetime_with_local_tzinfo
    self.assertEqual(datetime.fromtimestamp(int(format(dt, 'U'))), dt.replace(tzinfo=None))
AssertionError: datetime.datetime(2009, 5, 15, 23, 30, 30) != datetime.datetime(2009, 5, 16, 5, 30, 30)
 
======================================================================
FAIL: test_datetime_with_tzinfo (utils_tests.test_dateformat.DateFormatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\django\django\tests\utils_tests\test_dateformat.py", line 48, in test_datetime_with_tzinfo
    self.assertEqual(datetime.fromtimestamp(int(format(dt, 'U'))), dt.astimezone(ltz).replace(tzinfo=None))
AssertionError: datetime.datetime(2009, 5, 15, 23, 30, 30) != datetime.datetime(2009, 5, 16, 5, 30, 30)

From IRC:

mYk: "you can't set a timezone that isn't the system timezone on Windows (no tzset)"
mYk: "can you file a ticket? that's a release blocker"

Attachments (1)

fix-21161-no-tzset-on-windows.patch (5.7 KB ) - added by Raphaël Barrois 11 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Aymeric Augustin, 11 years ago

Component: Testing frameworkUtilities
Owner: changed from nobody to anonymous
Status: newassigned
Triage Stage: UnreviewedAccepted

Maybe my hunch isn't correct, but in any case it's a regression I introduced and I have to fix.

comment:2 by Raphaël Barrois, 11 years ago

Has patch: set

The utils_tests.test_dateformat.DateFormatTests tests have been fixed in 79ccd1a101e6379c5a49da18fc006816e5ed127c.

The tests in template_tests check comparisons between a timezone-aware datetime.datetime.now() and datetime.datetime.now(), thus relying on a valid tzset() function (or having the system TZ set to America/Chicago).

Moreover, they are duplicating the unit tests in tests/utils_tests/test_timesince.py, which didn't fail on Windows when the system timezone is behing America/Chicago.

The attached patch:

  • Disables the template_tests relying on tzset availability
  • Adds missing tests in tests/utils_tests/test_timesince.py for situations where the current timezone is behing America/Chicago
  • Disables those new tests on systems lacking tzset (e.g Windows).

by Raphaël Barrois, 11 years ago

comment:3 by Aymeric Augustin, 11 years ago

I've updated the patch to use the versions of TZ_SUPPORT and @requires_tz_support from django.test.utils and I've run the tests on Windows. I'll commit shortly.

comment:4 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 671757b507a60330ee37ef749a3f3a0301258f88:

Fixed #21161 -- Timezone-related tests on Windows.

Thanks Xelnor for the patch.

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