Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Make tests work with Python 3.13 #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/test_jsonlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down