#17463: timezones tests fail on Windows
-------------------------------------------+------------------------
Reporter: kmtracey | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: SVN
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
If I run the timezones tests on a Windows machine where the system
timezone is set to US/Eastern (my local time), I get 15 failures:
{{{
======================================================================
FAIL: test_change_editable (modeltests.timezones.tests.AdminTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
906, in test_change_editable
self.assertContains(response, e.dt.astimezone(EAT).time().isoformat())
File "C:\Users\kmtracey\django\trunk\django\test\testcases.py", line
536, in assertContains
msg_prefix + "Couldn't find '%s' in response" % text)
AssertionError: Couldn't find '13:20:30' in response
======================================================================
FAIL: test_change_readonly (modeltests.timezones.tests.AdminTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
920, in test_change_readonly
self.assertContains(response, t.created.astimezone(EAT).isoformat())
File "C:\Users\kmtracey\django\trunk\django\test\testcases.py", line
536, in assertContains
msg_prefix + "Couldn't find '%s' in response" % text)
AssertionError: Couldn't find '2011-12-25T23:46:22.104000+03:00' in
response
======================================================================
FAIL: test_changelist (modeltests.timezones.tests.AdminTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
894, in test_changelist
self.assertContains(response, e.dt.astimezone(EAT).isoformat())
File "C:\Users\kmtracey\django\trunk\django\test\testcases.py", line
536, in assertContains
msg_prefix + "Couldn't find '%s' in response" % text)
AssertionError: Couldn't find '2011-09-01T13:20:30+03:00' in response
======================================================================
FAIL: test_naive_datetime (modeltests.timezones.tests.NewDatabaseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
252, in test_naive_datetime
self.assertEqual(event.dt, dt.replace(tzinfo=EAT))
AssertionError: datetime.datetime(2011, 9, 1, 17, 20, 30,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50>) !=
datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=+0300)
======================================================================
FAIL: test_naive_datetime_with_microsecond
(modeltests.timezones.tests.NewDatabaseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\kmtracey\django\trunk\django\test\testcases.py", line
729, in skip_wrapper
return test_func(*args, **kwargs)
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
266, in test_naive_datetime_with_microsecond
self.assertEqual(event.dt, dt.replace(tzinfo=EAT))
AssertionError: datetime.datetime(2011, 9, 1, 17, 20, 30, 405060,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50>) !=
datetime.datetime(2011, 9, 1, 13, 20, 30, 405060, tzinfo=+0300)
======================================================================
FAIL: test_query_filter_with_naive_datetime
(modeltests.timezones.tests.NewDatabaseTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
358, in test_query_filter_with_naive_datetime
self.assertEqual(Event.objects.filter(dt__exact=dt).count(), 1)
AssertionError: 0 != 1
======================================================================
FAIL: test_form (modeltests.timezones.tests.NewFormsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
844, in test_form
self.assertEqual(form.cleaned_data['dt'], datetime.datetime(2011, 9,
1, 10, 20, 30, tzinfo=UTC))
AssertionError: datetime.datetime(2011, 9, 1, 13, 20, 30,
tzinfo=<django.utils.timezone.LocalTimezone object at 0x0000000003E24748>)
!= datetime.datetime(2011, 9, 1, 10, 20, 30,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50
>)
======================================================================
FAIL: test_model_form (modeltests.timezones.tests.NewFormsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
878, in test_model_form
self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 10, 20, 30,
tzinfo=UTC))
AssertionError: datetime.datetime(2011, 9, 1, 17, 20, 30,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50>) !=
datetime.datetime(2011, 9, 1, 10, 20, 30,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50>)
======================================================================
FAIL: test_split_form (modeltests.timezones.tests.NewFormsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
873, in test_split_form
self.assertEqual(form.cleaned_data['dt'], datetime.datetime(2011, 9,
1, 10, 20, 30, tzinfo=UTC))
AssertionError: datetime.datetime(2011, 9, 1, 13, 20, 30,
tzinfo=<django.utils.timezone.LocalTimezone object at 0x0000000003E24748>)
!= datetime.datetime(2011, 9, 1, 10, 20, 30,
tzinfo=<django.utils.timezone.UTC object at 0x0000000003228C50
>)
======================================================================
FAIL: test_date_and_time_template_filters
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
771, in test_date_and_time_template_filters
self.assertEqual(tpl.render(ctx), "2011-09-01 at 23:20:20")
AssertionError: u'2011-09-01 at 16:20:20' != '2011-09-01 at 23:20:20'
======================================================================
FAIL: test_get_current_timezone_templatetag
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
734, in test_get_current_timezone_templatetag
self.assertEqual(tpl.render(Context()), "Africa/Nairobi" if pytz else
"EAT")
AssertionError: u'Eastern Standard Time' != 'EAT'
======================================================================
FAIL: test_localtime_templatetag_and_filters
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
626, in test_localtime_templatetag_and_filters
self.assertEqual(actual, expected, '%s / %s: %r != %r' % (k1, k2,
actual, expected))
AssertionError: utc / on:
u'2011-09-01T06:20:30-04:00|2011-09-01T06:20:30-04:00|2011-09-01T10:20:30+00:00|2011-09-01T17:
20:30+07:00' !=
2011-09-01T13:20:30+03:00|2011-09-01T13:20:30+03:00|2011-09-01T10:20:30+00:00|2011-09-01T17:20:30+07:00'
======================================================================
FAIL: test_now_template_tag_uses_current_time_zone
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
796, in test_now_template_tag_uses_current_time_zone
self.assertEqual(tpl.render(Context({})), "+0300")
AssertionError: u'-0500' != '+0300'
======================================================================
FAIL: test_timezone_templatetag (modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
703, in test_timezone_templatetag
self.assertEqual(tpl.render(ctx),
"2011-09-01T13:20:30+03:00|2011-09-01T17:20:30+07:00|2011-09-01T13:20:30+03:00")
AssertionError:
u'2011-09-01T06:20:30-04:00|2011-09-01T17:20:30+07:00|2011-09-01T06:20:30-04:00'
!= '2011-09-01T13:20:30
+03:00|2011-09-01T17:20:30+07:00|2011-09-01T13:20:30+03:00'
======================================================================
FAIL: test_tz_template_context_processor
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
766, in test_tz_template_context_processor
self.assertEqual(tpl.render(RequestContext(HttpRequest())),
"Africa/Nairobi" if pytz else "EAT")
AssertionError: u'Eastern Standard Time' != 'EAT'
----------------------------------------------------------------------
Ran 70 tests in 1.177s
FAILED (failures=15, skipped=18)
Destroying test database for alias 'default' (':memory:')...
Destroying test database for alias 'other' (':memory:')...
}}}
I think the problem is that these tests set the `settings.TIME_ZONE` value
to an Eastern African value and expect that the underlying OS will start
respecting that settings. Per a note on the TIME_ZONE setting here:
https://docs.djangoproject.com/en/dev/ref/settings/#time-zone we don't
actually support, on Windows, setting TIME_ZONE in settings to something
that does not match the actual system time zone.
If I set the system timezone to Nairobi, things are better but still not
all-pass:
{{{
C:\Users\kmtracey\django\trunk\tests>runtests.py -v2
--settings=test_sqlite timezones
Importing application timezones
Creating test database for alias 'default' (':memory:')...
Creating tables ...
Creating table django_content_type
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_site
Creating table django_flatpage_sites
Creating table django_flatpage
Creating table django_redirect
Creating table django_session
Creating table django_comments
Creating table django_comment_flags
Creating table django_admin_log
Creating table timezones_event
Creating table timezones_maybeevent
Creating table timezones_timestamp
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Creating test database for alias 'other' (':memory:')...
Creating tables ...
Creating table django_content_type
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_site
Creating table django_flatpage_sites
Creating table django_flatpage
Creating table django_redirect
Creating table django_session
Creating table django_comments
Creating table django_comment_flags
Creating table django_admin_log
Creating table timezones_event
Creating table timezones_maybeevent
Creating table timezones_timestamp
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
test_change_editable (modeltests.timezones.tests.AdminTests) ... ok
test_change_editable_in_other_timezone
(modeltests.timezones.tests.AdminTests) ... ok
test_change_readonly (modeltests.timezones.tests.AdminTests) ... ok
test_change_readonly_in_other_timezone
(modeltests.timezones.tests.AdminTests) ... ok
test_changelist (modeltests.timezones.tests.AdminTests) ... ok
test_changelist_in_other_timezone (modeltests.timezones.tests.AdminTests)
... ok
test_auto_now_and_auto_now_add
(modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_aware_datetime_in_local_timezone
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_in_local_timezone_with_microsecond
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_in_local_timezone_with_microsecond_unsupported
(modeltests.timezones.tests.LegacyDatabaseTests) ...
skipped "Database doesn't support feature supports_timezones"
test_aware_datetime_in_other_timezone
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_in_other_timezone_unsupported
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_in_utc
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_in_utc_unsupported
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped "Database
doesn't support feature supports_timezones"
test_aware_datetime_unspported
(modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_naive_datetime (modeltests.timezones.tests.LegacyDatabaseTests) ...
ok
test_naive_datetime_with_microsecond
(modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_naive_datetime_with_microsecond_unsupported
(modeltests.timezones.tests.LegacyDatabaseTests) ... skipped 'Database has
feature supports_microsecond_precision'
test_query_aggregation (modeltests.timezones.tests.LegacyDatabaseTests)
... ok
test_query_date_related_filters
(modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_query_dates (modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_query_filter (modeltests.timezones.tests.LegacyDatabaseTests) ... ok
test_form (modeltests.timezones.tests.LegacyFormsTests) ... ok
test_form_with_ambiguous_time
(modeltests.timezones.tests.LegacyFormsTests) ... skipped 'this test
requires pytz'
test_form_with_non_existent_time
(modeltests.timezones.tests.LegacyFormsTests) ... skipped 'this test
requires pytz'
test_model_form (modeltests.timezones.tests.LegacyFormsTests) ... ok
test_split_form (modeltests.timezones.tests.LegacyFormsTests) ... ok
test_auto_now_and_auto_now_add
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_aware_datetime_in_local_timezone
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_aware_datetime_in_local_timezone_with_microsecond
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_aware_datetime_in_local_timezone_with_microsecond_unsupported
(modeltests.timezones.tests.NewDatabaseTests) ... skipped 'Database has
feature supports_microsecond_precision'
test_aware_datetime_in_other_timezone
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_aware_datetime_in_utc (modeltests.timezones.tests.NewDatabaseTests)
... ok
test_naive_datetime (modeltests.timezones.tests.NewDatabaseTests) ... ok
test_naive_datetime_with_microsecond
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_naive_datetime_with_microsecond_unsupported
(modeltests.timezones.tests.NewDatabaseTests) ... skipped 'Database has
feature supports_microsecond_precision'
test_null_datetime (modeltests.timezones.tests.NewDatabaseTests) ... ok
test_query_aggregation (modeltests.timezones.tests.NewDatabaseTests) ...
ok
test_query_date_related_filters
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_query_dates (modeltests.timezones.tests.NewDatabaseTests) ... ok
test_query_filter (modeltests.timezones.tests.NewDatabaseTests) ... ok
test_query_filter_with_naive_datetime
(modeltests.timezones.tests.NewDatabaseTests) ... ok
test_query_filter_with_pytz_timezones
(modeltests.timezones.tests.NewDatabaseTests) ... skipped 'this test
requires pytz'
test_form (modeltests.timezones.tests.NewFormsTests) ... ok
test_form_with_ambiguous_time (modeltests.timezones.tests.NewFormsTests)
... skipped 'this test requires pytz'
test_form_with_non_existent_time
(modeltests.timezones.tests.NewFormsTests) ... skipped 'this test requires
pytz'
test_form_with_other_timezone (modeltests.timezones.tests.NewFormsTests)
... ok
test_model_form (modeltests.timezones.tests.NewFormsTests) ... ok
test_split_form (modeltests.timezones.tests.NewFormsTests) ... ok
test_aware_datetime_in_local_timezone
(modeltests.timezones.tests.SerializationTests) ... ok
test_aware_datetime_in_other_timezone
(modeltests.timezones.tests.SerializationTests) ... ok
test_aware_datetime_in_utc (modeltests.timezones.tests.SerializationTests)
... ok
test_aware_datetime_with_microsecond
(modeltests.timezones.tests.SerializationTests) ... ok
test_naive_datetime (modeltests.timezones.tests.SerializationTests) ... ok
test_naive_datetime_with_microsecond
(modeltests.timezones.tests.SerializationTests) ... ok
test_date_and_time_template_filters
(modeltests.timezones.tests.TemplateTests) ... ok
test_date_and_time_template_filters_honor_localtime
(modeltests.timezones.tests.TemplateTests) ... ok
test_get_current_timezone_templatetag
(modeltests.timezones.tests.TemplateTests) ... FAIL
test_get_current_timezone_templatetag_invalid_argument
(modeltests.timezones.tests.TemplateTests) ... ok
test_get_current_timezone_templatetag_with_pytz
(modeltests.timezones.tests.TemplateTests) ... skipped 'this test requires
pytz'
test_localtime_filters_do_not_raise_exceptions
(modeltests.timezones.tests.TemplateTests) ... ok
test_localtime_filters_with_pytz
(modeltests.timezones.tests.TemplateTests) ... skipped 'this test requires
pytz'
test_localtime_templatetag_and_filters
(modeltests.timezones.tests.TemplateTests) ... ok
test_localtime_templatetag_invalid_argument
(modeltests.timezones.tests.TemplateTests) ... ok
test_localtime_with_time_zone_setting_set_to_none
(modeltests.timezones.tests.TemplateTests) ... ok
test_now_template_tag_uses_current_time_zone
(modeltests.timezones.tests.TemplateTests) ... ok
test_timezone_templatetag (modeltests.timezones.tests.TemplateTests) ...
ok
test_timezone_templatetag_invalid_argument
(modeltests.timezones.tests.TemplateTests) ... ok
test_timezone_templatetag_with_pytz
(modeltests.timezones.tests.TemplateTests) ... skipped 'this test requires
pytz'
test_tz_template_context_processor
(modeltests.timezones.tests.TemplateTests) ... FAIL
======================================================================
FAIL: test_get_current_timezone_templatetag
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
734, in test_get_current_timezone_temp
latetag
self.assertEqual(tpl.render(Context()), "Africa/Nairobi" if pytz else
"EAT")
AssertionError: u'E. Africa Standard Time' != 'EAT'
======================================================================
FAIL: test_tz_template_context_processor
(modeltests.timezones.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Users\kmtracey\django\trunk\tests\modeltests\timezones\tests.py", line
766, in test_tz_template_context_proce
ssor
self.assertEqual(tpl.render(RequestContext(HttpRequest())),
"Africa/Nairobi" if pytz else "EAT")
AssertionError: u'E. Africa Standard Time' != 'EAT'
----------------------------------------------------------------------
Ran 70 tests in 1.060s
FAILED (failures=2, skipped=18)
Destroying test database for alias 'default' (':memory:')...
Destroying test database for alias 'other' (':memory:')...
}}}
Those 2 look fairly innocuous/fixable, but I'm not entirely sure how to
approach fixing these tests in general. It seems the issue is in the
tests, not in the underlying new timezone support code. The tests are
assuming they can set TIME_ZONE different than the underlying system time,
and we don't support that on Windows.....
--
Ticket URL: <https://code.djangoproject.com/ticket/17463>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.