Skip to content

Commit

Permalink
Adjust tests for taskName attribute added in Python 3.12
Browse files Browse the repository at this point in the history
gh-91513: Added taskName attribute to logging module for use with
asyncio tasks.
python/cpython#91513
  • Loading branch information
hrnciar committed Jul 4, 2023
1 parent 5f85723 commit a27f9d2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_jsonlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_percentage_format(self):
log_json = json.loads(self.buffer.getvalue())

self.assertEqual(log_json["message"], msg)
self.assertEqual(log_json.keys(), {'levelname', 'message', 'filename', 'lineno', 'asctime'})
self.assertEqual(log_json.keys(), {'levelname', 'message', 'filename', 'lineno', 'asctime', 'taskName'})

def test_rename_base_field(self):
fr = jsonlogger.JsonFormatter(rename_fields={'message': '@message'})
Expand Down Expand Up @@ -274,7 +274,7 @@ def encode_complex(z):

self.log.info(" message", extra=value)
msg = self.buffer.getvalue()
self.assertEqual(msg, "{\"message\": \" message\", \"special\": [3.0, 8.0]}\n")
self.assertEqual(msg, "{\"message\": \" message\", \"taskName\": null, \"special\": [3.0, 8.0]}\n")

def test_rename_reserved_attrs(self):
log_format = lambda x: ['%({0:s})s'.format(i) for i in x]
Expand All @@ -296,7 +296,7 @@ def test_rename_reserved_attrs(self):
self.log.info("message")

msg = self.buffer.getvalue()
self.assertEqual(msg, '{"error.type": null, "error.message": null, "log.origin.function": "test_rename_reserved_attrs", "log.level": "INFO", "log.origin.file.name": "test_jsonlogger", "process.name": "MainProcess", "process.thread.name": "MainThread", "log.message": "message"}\n')
self.assertEqual(msg, '{"taskName": null, "error.type": null, "error.message": null, "log.origin.function": "test_rename_reserved_attrs", "log.level": "INFO", "log.origin.file.name": "test_jsonlogger", "process.name": "MainProcess", "process.thread.name": "MainThread", "log.message": "message"}\n')

def test_merge_record_extra(self):
record = logging.LogRecord("name", level=1, pathname="", lineno=1, msg="Some message", args=None, exc_info=None)
Expand Down

0 comments on commit a27f9d2

Please sign in to comment.