Replace deprecated datetime.datetime.utcnow
It was deprecated in Python 3.12 . Change-Id: I671dc63a6c39a52f9be045ab40e36433af34d84f
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
import datetime
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from cloudkitty import state
|
from cloudkitty import state
|
||||||
from cloudkitty import tests
|
from cloudkitty import tests
|
||||||
@@ -29,14 +29,14 @@ class DBStateManagerTest(tests.TestCase):
|
|||||||
self.assertEqual(name, 'testuser_osrtf')
|
self.assertEqual(name, 'testuser_osrtf')
|
||||||
|
|
||||||
def test_state_access(self):
|
def test_state_access(self):
|
||||||
now = datetime.datetime.utcnow()
|
now = timeutils.utcnow()
|
||||||
self.sm.set_state(now)
|
self.sm.set_state(now)
|
||||||
result = self.sm.get_state()
|
result = self.sm.get_state()
|
||||||
self.assertEqual(result, str(now))
|
self.assertEqual(result, str(now))
|
||||||
|
|
||||||
def test_metadata_access(self):
|
def test_metadata_access(self):
|
||||||
metadata = {'foo': 'bar'}
|
metadata = {'foo': 'bar'}
|
||||||
now = datetime.datetime.utcnow()
|
now = timeutils.utcnow()
|
||||||
self.sm.set_state(now)
|
self.sm.set_state(now)
|
||||||
self.sm.set_metadata(metadata)
|
self.sm.set_metadata(metadata)
|
||||||
result = self.sm.get_metadata()
|
result = self.sm.get_metadata()
|
||||||
|
@@ -22,6 +22,8 @@ import random
|
|||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from cloudkitty import json_utils as json
|
from cloudkitty import json_utils as json
|
||||||
|
|
||||||
|
|
||||||
@@ -588,7 +590,7 @@ def main():
|
|||||||
generators = [compute, image, volume, net_bw, floating]
|
generators = [compute, image, volume, net_bw, floating]
|
||||||
|
|
||||||
# Date
|
# Date
|
||||||
now = datetime.datetime.utcnow()
|
now = timeutils.utcnow()
|
||||||
hour_delta = datetime.timedelta(hours=1)
|
hour_delta = datetime.timedelta(hours=1)
|
||||||
cur_date = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
cur_date = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||||
cur_month = cur_date.month
|
cur_month = cur_date.month
|
||||||
|
Reference in New Issue
Block a user