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

Update pytest xml parser and markdown gist results #45

Merged
merged 7 commits into from
Jan 16, 2025

Conversation

trishaange01
Copy link
Contributor

This change includes adding a class for parsing pytest xml, updating test artifacts, and adding a pytest_failure parameter for parser test. The parser class adds test details in gist results such as parameters used for the test, error message, and inline link for test description.

Comment on lines +356 to +362
if test_function_module != "":
if test_name_function != "":
if test_function_module in test_links:
test_permalink = test_links[test_function_module] + "#" + test_function_module + "." + test_name_function
test_name_link = f"[{test_name}]({test_permalink})"
else:
if test_function_module in test_links:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if test_function_module is in test_links can be joined with the first check if the test_function_module != "".

Comment on lines +291 to +300
# Convert remaining string to a dictionary
param_dict = ast.literal_eval(new_param)
if param_dict:
for key, value in param_dict.items():
# Convert parameters back to string
new_updated = "'" + key + "'" + ": " + str(value)
param_list.append(new_updated)
insert_param_name = param_name + "="
param_list.insert(0, insert_param_name)
param_list_string = " \n".join(param_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will .replace(", '", ",\n'") not work for this?

Comment on lines +331 to +340
if len(prop_list) > 1:
for props in prop_list:
if len(props) > 0:
# Remove leading spaces
prop_strip = props.lstrip()
prop_list_updated.append(prop_strip)
if len(prop_list_updated) > 0:
new_props = " ".join(prop_list_updated)
# Combine exception type, message, and parameters
exctype_message = "\n" + " " + new_props + " ( " + exc_param_value + " )"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's an example of a property value that satisfies this condition and requires such parsing?

Comment on lines +77 to 78
pytest_failures_details = "No failures"
pytest_failures_details = "Invalid" if pytest_tests_status == "⛔" else pytest_failures_details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine "No failures" after else instead

@@ -243,13 +245,153 @@ def get_payload_parsed(self):
payload_param = param
return (payload, payload_param)

class PytestFailure(xmlParser):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of inheritance for maintaining code structure and reusability

Copy link
Contributor

@jpineda3 jpineda3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be merged now. Mods can be done later.

@kimpaller kimpaller merged commit a369cf4 into sdgtt:master Jan 16, 2025
2 checks passed
This change adds a separate class for parsing pytest results xml

Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
This change updates the stucture of pytest results  to gistfor markdown  template

Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
Signed-off-by: Trisha De Vera <Trisha.Devera@analog.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants