Skip to content

Commit

Permalink
Fixed IsoDateTimeRangeFieldTests for Django 3.1
Browse files Browse the repository at this point in the history
Closes carltongibson#1219. ISO 8601 formats will retain tzinfo even when USE_TZ=False.
  • Loading branch information
carltongibson committed May 20, 2020
1 parent 6fb5f3e commit 7428e47
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ def test_field(self):
f = IsoDateTimeRangeField()
self.assertEqual(len(f.fields), 2)

@override_settings(USE_TZ=False)
def test_clean(self):
w = RangeWidget()
f = IsoDateTimeRangeField(widget=w)
self.assertEqual(
f.clean(['2015-01-01T10:30:01.123000+01:00', '2015-01-10T08:45:02.345000+01:00']),
slice(datetime(2015, 1, 1, 9, 30, 1, 123000),
datetime(2015, 1, 10, 7, 45, 2, 345000)))
expected = slice(
datetime(2015, 1, 1, 9, 30, 1, 123000, tzinfo=timezone.utc),
datetime(2015, 1, 10, 7, 45, 2, 345000, tzinfo=timezone.utc)
)
actual = f.clean(['2015-01-01T10:30:01.123000+01:00', '2015-01-10T08:45:02.345000+01:00'])
self.assertEqual(expected, actual)


class TimeRangeFieldTests(TestCase):
Expand Down

0 comments on commit 7428e47

Please sign in to comment.