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)
Change History (5)
comment:1 by , 11 years ago
Component: | Testing framework → Utilities |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 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 ontzset
availability - Adds missing tests in
tests/utils_tests/test_timesince.py
for situations where the current timezone is behingAmerica/Chicago
- Disables those new tests on systems lacking
tzset
(e.g Windows).
by , 11 years ago
Attachment: | fix-21161-no-tzset-on-windows.patch added |
---|
comment:3 by , 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 , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Maybe my hunch isn't correct, but in any case it's a regression I introduced and I have to fix.