From e762ada33fc7fea6fdc8f8acb58375b9443eb9b8 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Fri, 12 Jul 2024 14:51:10 +0200 Subject: [PATCH] Mock time.time_ns in test_rfc5424_isotime_format_no_microseconds for py3.13 In python 3.13, the logging module has moved to use time_ns() instead of time() for the `created` attribute [1]. [1] https://github.com/python/cpython/commit/1316692e8c7c1e1f3b6639e51804f9db5ed892ea Change-Id: I8dfd02964fc278ac16bb311ed102a7cfc63aa059 --- oslo_log/tests/unit/test_log.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py index 7c066aef..968e4050 100644 --- a/oslo_log/tests/unit/test_log.py +++ b/oslo_log/tests/unit/test_log.py @@ -991,6 +991,8 @@ class ContextFormatterTestCase(LogTestBase): get_fake_datetime( datetime.datetime(2015, 12, 16, 13, 54, 26))) @mock.patch("time.time", new=mock.Mock(return_value=1450274066.000000)) + @mock.patch("time.time_ns", + new=mock.Mock(return_value=1450274066000000000)) @mock.patch("dateutil.tz.tzlocal", new=mock.Mock(return_value=tz.tzutc())) def test_rfc5424_isotime_format_no_microseconds(self): self.config(logging_default_format_string="%(isotime)s %(message)s")