Merge "Replace datetime.datetime.utcnow()"

This commit is contained in:
Zuul 2024-09-29 07:02:03 +00:00 committed by Gerrit Code Review
commit 5c312eb98a
3 changed files with 5 additions and 7 deletions

View File

@ -13,7 +13,6 @@
import collections
import contextlib
import datetime as dt
import itertools
import pydoc
import re
@ -24,6 +23,7 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import reflection
from oslo_utils import timeutils as oslo_timeutils
from heat.common import exception
from heat.common.i18n import _
@ -58,8 +58,6 @@ cfg.CONF.import_opt('error_wait_time', 'heat.common.config')
LOG = logging.getLogger(__name__)
datetime = dt.datetime
def _register_class(resource_type, resource_class):
resources.global_env().register_class(resource_type, resource_class)
@ -1675,7 +1673,7 @@ class Resource(status.ResourceStatus):
LOG.info('updating %s', self)
self.updated_time = datetime.utcnow()
self.updated_time = oslo_timeutils.utcnow()
if new_requires is not None:
self.requires = self.requires | new_requires

View File

@ -604,7 +604,7 @@ class WaitConditionUpdateTest(common.HeatTestCase):
now = timeutils.utcnow()
fake_clock = [now + datetime.timedelta(0, t)
for t in (0, 0.001, 0.1, 4.1, 5.1)]
for t in (0, 0, 0.001, 0.1, 4.1, 5.1, 5.1)]
timeutils.set_time_override(fake_clock)
self.addCleanup(timeutils.clear_time_override)

View File

@ -12,7 +12,6 @@
# under the License.
import collections
import datetime
import itertools
import json
import os
@ -22,6 +21,7 @@ import uuid
import eventlet
from oslo_config import cfg
from oslo_utils import timeutils as oslo_timeutils
from heat.common import exception
from heat.common.i18n import _
@ -600,7 +600,7 @@ class ResourceTest(common.HeatTestCase):
res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.store()
self.assertIsNone(res.updated_time)
res.updated_time = datetime.datetime.utcnow()
res.updated_time = oslo_timeutils.utcnow()
res.store()
self.assertIsNotNone(res.updated_time)