blob: 8421617783dae94338a712286ca61bca2a6fe5f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
diff --git a/tests/test_jsonlogger.py b/tests/test_jsonlogger.py
index af369d2..068e760 100644
--- a/tests/test_jsonlogger.py
+++ b/tests/test_jsonlogger.py
@@ -176,13 +176,17 @@ def test_json_default_encoder(self):
"1900-01-01T00:00:00")
@unittest.mock.patch('time.time', return_value=1500000000.0)
- def test_json_default_encoder_with_timestamp(self, time_mock):
+ @unittest.mock.patch('time.time_ns', return_value=1500000000000000000)
+ def test_json_default_encoder_with_timestamp(self, time_ns_mock, time_mock):
fr = jsonlogger.JsonFormatter(timestamp=True)
self.log_handler.setFormatter(fr)
self.log.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)
log_json = json.loads(self.buffer.getvalue())
self.assertEqual(log_json.get("timestamp"), "2017-07-14T02:40:00+00:00")
|