#31608: forms.DateTimeField parses ISO 8601 datetime with offset as aware when
USE_TZ is False.
-------------------------------------------+------------------------
               Reporter:  Carlton Gibson   |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Forms            |        Version:  3.1
               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                |
-------------------------------------------+------------------------
 The following test fails on 3.1a1.

 > `USE_TZ`: If this is set to True, Django will use timezone-aware
 datetimes internally. Otherwise, Django will use naive datetimes in local
 time.

 {{{
 diff --git a/tests/forms_tests/field_tests/test_datetimefield.py
 b/tests/forms_tests/field_tests/test_datetimefield.py
 index f0e6ada3c5..ed035497d8 100644
 --- a/tests/forms_tests/field_tests/test_datetimefield.py
 +++ b/tests/forms_tests/field_tests/test_datetimefield.py
 @@ -2,8 +2,8 @@ from datetime import date, datetime

  from django.core.exceptions import ValidationError
  from django.forms import DateTimeField
 -from django.test import SimpleTestCase
 -from django.utils.timezone import get_fixed_timezone, utc
 +from django.test import SimpleTestCase, override_settings
 +from django.utils.timezone import get_fixed_timezone, is_naive, utc


  class DateTimeFieldTest(SimpleTestCase):
 @@ -65,6 +65,12 @@ class DateTimeFieldTest(SimpleTestCase):
              with self.subTest(value=value):
                  self.assertEqual(f.clean(value), expected_datetime)

 +    @override_settings(USE_TZ=False)
 +    def test_use_tz_false(self):
 +        f = DateTimeField()
 +        value = '2014-09-23T22:34Z'
 +        self.assertTrue(is_naive(f.clean(value)))
 +
      def test_datetimefield_clean_invalid(self):
          f = DateTimeField()
          msg = "'Enter a valid date/time.'"
 }}}

 Expected behaviour is to return a naive datetime.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31608>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.1f1a579420fc448fc1d53390626ca2fe%40djangoproject.com.

Reply via email to