Fix Python3 iso8601 UTC change
Python 3 changed the iso8601 module iso8601.iso8601.Utc() function to iso8601.UTC. This is compatible with Python2.7. Change-Id: I886c1408a227dd0cc37faeab48738157c9c931cb Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
parent
8d3ca676cf
commit
c9d66fb5f4
|
@ -39,7 +39,7 @@ def datetime_or_none(dt):
|
|||
# NOTE(danms): Legacy objects from sqlalchemy are stored in UTC,
|
||||
# but are returned without a timezone attached.
|
||||
# As a transitional aid, assume a tz-naive object is in UTC.
|
||||
return dt.replace(tzinfo=iso8601.iso8601.Utc())
|
||||
return dt.replace(tzinfo=iso8601.UTC)
|
||||
else:
|
||||
return dt
|
||||
raise ValueError('A datetime.datetime is required here')
|
||||
|
|
|
@ -123,7 +123,7 @@ class TestUtils(test_base.TestCase):
|
|||
dt = timeutils.parse_isotime(timeutils.isotime(naive_dt))
|
||||
self.assertEqual(utils.datetime_or_none(dt), dt)
|
||||
self.assertEqual(utils.datetime_or_none(dt),
|
||||
naive_dt.replace(tzinfo=iso8601.iso8601.Utc(),
|
||||
naive_dt.replace(tzinfo=iso8601.UTC,
|
||||
microsecond=0))
|
||||
self.assertEqual(utils.datetime_or_none(None), None)
|
||||
self.assertRaises(ValueError, utils.datetime_or_none, 'foo')
|
||||
|
|
Loading…
Reference in New Issue