You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
4 weeks ago
|
From c6e353b56a925b3549a73e6ac31b7478950afed3 Mon Sep 17 00:00:00 2001
|
||
|
From: Karolina Surma <ksurma@redhat.com>
|
||
|
Date: Mon, 10 Jun 2024 13:31:29 +0200
|
||
|
Subject: [PATCH] Python 3.13 compatibility: logger creates values with time_ns
|
||
|
|
||
|
---
|
||
|
tests/tests.py | 8 ++++++--
|
||
|
1 file changed, 6 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/tests/tests.py b/tests/tests.py
|
||
|
index fc907d6..669cb32 100644
|
||
|
--- a/tests/tests.py
|
||
|
+++ b/tests/tests.py
|
||
|
@@ -170,13 +170,17 @@ class TestJsonLogger(unittest.TestCase):
|
||
|
"1900-01-01T00:00:00")
|
||
|
|
||
|
@unittest.mock.patch('time.time', return_value=1500000000.0)
|
||
|
- def testJsonDefaultEncoderWithTimestamp(self, time_mock):
|
||
|
+ @unittest.mock.patch('time.time_ns', return_value=1500000000000000000)
|
||
|
+ def testJsonDefaultEncoderWithTimestamp(self, time_ns_mock, time_mock):
|
||
|
fr = jsonlogger.JsonFormatter(timestamp=True)
|
||
|
self.logHandler.setFormatter(fr)
|
||
|
|
||
|
self.logger.info("Hello")
|
||
|
|
||
|
- self.assertTrue(time_mock.called)
|
||
|
+ if sys.version_info < (3, 13):
|
||
|
+ self.assertTrue(time_mock.called)
|
||
|
+ else:
|
||
|
+ self.assertTrue(time_ns_mock.called)
|
||
|
logJson = json.loads(self.buffer.getvalue())
|
||
|
self.assertEqual(logJson.get("timestamp"), "2017-07-14T02:40:00+00:00")
|
||
|
|
||
|
--
|
||
|
2.44.0
|
||
|
|