parkhojeong commented on code in PR #66230:
URL: https://github.com/apache/airflow/pull/66230#discussion_r3180889575
##########
shared/logging/tests/logging/test_percent_formatter.py:
##########
@@ -40,3 +40,40 @@ def test_lineno_is_none(self):
)
assert formatted == "test.py:0 our msg"
+
+ @mock.patch("airflow_shared.logging.percent_formatter.os.getpid")
+ @mock.patch("airflow_shared.logging.percent_formatter.threading.get_ident")
+ def test_process_thread_missing_returns_live_values(self, mock_get_ident,
mock_getpid):
+ mock_getpid.return_value = 123
+ mock_get_ident.return_value = 456
+ fmt = "%(process)d %(thread)d %(lineno)d %(message)s"
+ renderer = PercentFormatRender(fmt)
+
+ event_dict = {"event": "test message"}
+ result = renderer(None, "info", event_dict)
+ assert result.startswith("123 456 0 test message")
+
+ @mock.patch("airflow_shared.logging.percent_formatter.os.getpid")
+ @mock.patch("airflow_shared.logging.percent_formatter.threading.get_ident")
+ def test_process_thread_unknown_string_returns_live_values(self,
mock_get_ident, mock_getpid):
+ mock_getpid.return_value = 123
+ mock_get_ident.return_value = 456
+ fmt = "%(process)d %(thread)d %(lineno)d %(message)s"
+ renderer = PercentFormatRender(fmt)
+
+ event_dict = {
+ "event": "test message",
+ "process": "(unknown)",
+ "thread": "(unknown)",
+ "lineno": "(unknown)",
Review Comment:
the test includes lineno but function name has only process and thread.
is there any reason using only two keys?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]