Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust tests for taskName attribute added in Python 3.12 #178

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions tests/test_jsonlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_default_format(self):
def test_percentage_format(self):
fr = jsonlogger.JsonFormatter(
# All kind of different styles to check the regex
'[%(levelname)8s] %(message)s %(filename)s:%(lineno)d %(asctime)'
'[%(levelname)8s] %(message)s %(filename)s:%(lineno)d %(asctime) %(taskName)'
)
self.log_handler.setFormatter(fr)

Expand All @@ -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