-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix missing argument in test_macos_format_basic IT #1478
Conversation
@@ -45,7 +42,7 @@ def get_connection_configuration(): | |||
return logcollector.DEFAULT_AUTHD_REMOTED_SIMULATOR_CONFIGURATION | |||
|
|||
|
|||
@pytest.mark.parametrize('macos_message', macos_log_messages) | |||
@pytest.mark.parametrize('macos_message', macos_log_messages, ids=[x['id'] for x in macos_log_messages]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x["id"]
don't use letters for arrays, use descriptive names, for examples: "id_list"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but actually the array is called macos_log_message. In this case the x
refers to each element of this array. Each element has a map, that's why we use x['id]
, but yes, I've renamed it to log_message as each element of the array is a log message.
@@ -760,4 +761,6 @@ def format_macos_message_pattern(process_name, message, type='log', subsystem=No | |||
elif type == 'activity': | |||
macos_message = f"{process_name}\[\d+\]: Created Activity ID.* Description: {message}" | |||
|
|||
assert macos_message is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to put a message indicating the reason when the assert fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -45,7 +42,7 @@ def get_connection_configuration(): | |||
return logcollector.DEFAULT_AUTHD_REMOTED_SIMULATOR_CONFIGURATION | |||
|
|||
|
|||
@pytest.mark.parametrize('macos_message', macos_log_messages) | |||
@pytest.mark.parametrize('macos_message', macos_log_messages, ids=[log_message['id'] for log_message in macos_log_messages]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected_macos_message = logcollector.format_macos_message_pattern( | ||
'custom_log', | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, macos_message['subsystem'], | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, 'log', macos_message['subsystem'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check PEP-8 guide style`
E501 line too long (127 > 120 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logcollector.TEMPLATE_OSLOG_MESSAGE, 'log', macos_message['subsystem'], | |
logcollector.TEMPLATE_OSLOG_MESSAGE, subsystem=macos_message['subsystem'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the name of the argument to specify its value instead of putting the rest of the preceding arguments one by one. Python is flexible in this topic.
Also, in this case 'log' is the default value, so it is not necessary .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected_macos_message = logcollector.format_macos_message_pattern( | ||
'custom_log', | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, macos_message['subsystem'], | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, 'log', macos_message['subsystem'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logcollector.TEMPLATE_OSLOG_MESSAGE, 'log', macos_message['subsystem'], | |
logcollector.TEMPLATE_OSLOG_MESSAGE, subsystem=macos_message['subsystem'], |
expected_macos_message = logcollector.format_macos_message_pattern( | ||
'custom_log', | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, macos_message['subsystem'], | ||
logcollector.TEMPLATE_OSLOG_MESSAGE, 'log', macos_message['subsystem'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the name of the argument to specify its value instead of putting the rest of the preceding arguments one by one. Python is flexible in this topic.
Also, in this case 'log' is the default value, so it is not necessary .
@@ -479,6 +479,7 @@ def add_log_data(log_path, log_line_message, size_kib=1024, line_start=1, print_ | |||
return line_start + lines - 1 | |||
return 0 | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for pep8 requireements.
LGTM |
ty |
Description
It seems that
format_macos_message_pattern
' function arguments changed recently and were not updated intests/integration/test_logcollector/test_macos/test_macos_format_basic.py
leading to a logic failure because of a missing specification of the log type. This PR aims to fix that problem.Configuration options
Tests
pycodestyle --max-line-length=120 --show-source --show-pep8 file.py
.provision_documentation.sh
generate the docs without errors.