Contains the API for end users as well as helper functions and classes to build Allure adapters for Python test frameworks
Overall
score
94%
Build a test utility module that captures and attaches various artifacts during test execution for debugging and documentation purposes.
Your module should provide a utility class that can:
Attach text-based logs: Accept a string containing log data and attach it to the test report with a descriptive name.
Attach JSON data: Accept Python dictionaries and serialize them as JSON before attaching to the test report.
Attach screenshot files: Accept a file path to an image and attach it to the test report. The attachment should be properly labeled.
Attach HTML reports: Accept HTML content as a string and attach it to the test report.
Given a string "Error occurred at line 42", when attached as a log, then it appears in the test report as a TEXT attachment named "Test Log" @test
Given a dictionary {"status": "success", "count": 5}, when attached as JSON data, then it appears in the test report as a JSON attachment named "API Response" @test
Given a file path "./screenshot.png" that exists, when attached as a screenshot, then it appears in the test report as an image attachment named "Page Screenshot" @test
Given an HTML string "<html><body><h1>Test Results</h1></body></html>", when attached as an HTML report, then it appears in the test report as an HTML attachment named "HTML Report" @test
@generates
class TestReporter:
"""Utility class for attaching various artifacts to test reports."""
def attach_log(self, log_content: str, name: str = "Test Log") -> None:
"""Attach text log content to the test report.
Args:
log_content: The log text to attach
name: The name for the attachment
"""
pass
def attach_json_data(self, data: dict, name: str = "JSON Data") -> None:
"""Attach JSON data to the test report.
Args:
data: Dictionary or object to serialize as JSON
name: The name for the attachment
"""
pass
def attach_screenshot_file(self, file_path: str, name: str = "Screenshot") -> None:
"""Attach an image file to the test report.
Args:
file_path: Path to the image file
name: The name for the attachment
"""
pass
def attach_html_report(self, html_content: str, name: str = "HTML Report") -> None:
"""Attach HTML content to the test report.
Args:
html_content: The HTML string to attach
name: The name for the attachment
"""
passProvides test reporting and attachment capabilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-allure-python-commonsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10