Qase Python Commons
qase-python-commons is a foundational Python library providing common models, data structures, and utilities used across various Qase TestOps integration tools, such as reporters for Pytest, Behave, and Robot Framework. It streamlines data exchange and standardizes reporting formats for Qase TestOps. The current version is 5.1.1, and it's actively maintained with frequent updates, often alongside its sister reporter libraries.
Common errors
-
ModuleNotFoundError: No module named 'qaseio.commons'
cause The `qase-python-commons` library is not installed or the virtual environment is not activated.fixInstall the library using `pip install qase-python-commons` and ensure your Python environment is correctly configured. -
pydantic.error_wrappers.ValidationError: ... field required
cause When creating `Result` or `Step` models, a required field (e.g., `test_id`, `status`, `start_time`) was omitted or provided with an incorrect type, failing Pydantic validation.fixReview the constructor arguments for `Result` and `Step` models. Ensure all required fields are present and their values match the expected data types (e.g., ISO-formatted strings for times, `Status` enum for status).
Warnings
- breaking The handling of test-level tags was refactored in versions 5.1.0/5.1.1. Previously, custom integrations might have directly manipulated tag fields. Now, `add_tag()` and `tags` attribute on the `Result` model should be used.
- gotcha This library explicitly depends on `pydantic<3.0.0`. If you have Pydantic v2.x installed globally or in your environment for other projects, it might lead to dependency resolution errors or runtime issues due to API differences between Pydantic v1 and v2.
Install
-
pip install qase-python-commons
Imports
- Result
from qaseio.commons.models import Result
- Status
from qaseio.commons.models import Status
- Step
from qaseio.commons.models import Step
Quickstart
from qaseio.commons.models import Result, Step, Status
import datetime
# Create a test result object
result = Result(
test_id='QASE-123',
status=Status.PASSED,
start_time=datetime.datetime.now().isoformat(),
end_time=datetime.datetime.now().isoformat(),
duration=150, # milliseconds
message='Simple test passed.'
)
# Add a step to the test result
step1 = Step(
status=Status.PASSED,
position=1,
action='Verify initial setup',
start_time=datetime.datetime.now().isoformat(),
end_time=datetime.datetime.now().isoformat(),
duration=100
)
result.steps.append(step1)
# Add tags to the result
result.add_tag('smoke_test')
result.add_tag('frontend')
print(f"Result created for Test ID: {result.test_id}")
print(f"Status: {result.status.value}")
print(f"Duration: {result.duration}ms")
print(f"Tags: {', '.join(result.tags)}")
print(f"Number of steps: {len(result.steps)}")