Registry / testing / allure-python-commons

allure-python-commons

JSON →
library2.15.3pypypi✓ verified 49d ago

allure-python-commons is a core Python library providing the API for end-users and helper functions/classes to build Allure adapters for various Python test frameworks. It is currently at version 2.15.3 and maintains a frequent release cadence with multiple minor/patch releases every few weeks or months, ensuring active development and support.

testing
pip install allure-python-commons
Install & Compatibility
Where this runs
tested against v2.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.930 runs
installs and imports cleanly · install 0.0s · import 0.087s · 18.7MB
glibc
py 3.103.930 runs
installs and imports cleanly · install 1.7s · import 0.078s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

allure
import allure
The main entry point for Allure API functions like step, attach, and dynamic annotations.
LabelType
from allure_commons.types import LabelType
Used for standardizing labels, e.g., allure.label(LabelType.SEVERITY, allure.severity_level.CRITICAL).

This example demonstrates basic usage of `allure.step` and `allure.attach` within a Python function. While `allure-python-commons` provides the API, generating an actual Allure Report requires integration with a test framework adapter (like `allure-pytest`) and the Allure Report command-line tool. The output will typically be `.json` and `.xml` files in a designated directory, which are then processed by the Allure CLI tool.

import allure import os def my_function_with_steps(): with allure.step("Step 1: Perform initial setup"): print("Executing setup...") allure.attach("Setup log content", name="setup_log", attachment_type=allure.attachment_type.TEXT) with allure.step("Step 2: Process data"): data = "some_data_to_process" allure.dynamic.parameter("input_data", data) print(f"Processing data: {data}") processed_data = data.upper() allure.attach(processed_data, name="processed_output", attachment_type=allure.attachment_type.TEXT) with allure.step("Step 3: Final verification"): result = "success" allure.dynamic.label("result", result) print(f"Verification result: {result}") if __name__ == "__main__": # In a real test framework (e.g., pytest), this function would be a test. # The Allure adapter would then capture these calls to build the report. print("Running a simulated test function using allure-python-commons API.") print("Note: To generate an actual Allure Report, you need a test runner (e.g., pytest) configured with an Allure adapter (e.g., allure-pytest) and the Allure Report CLI tool.") my_function_with_steps() print("API calls made. Check the output directory configured by your Allure adapter.")
Debug
Known issues
breakingVersion 2.14.0 dropped official support for Python 3.7. Ensure your Python environment is 3.8 or newer for the latest versions of `allure-python-commons` and its adapters.
fix
Upgrade Python to 3.8 or later, or use an older version of `allure-python-commons` compatible with Python 3.7 (e.g., <2.14.0).
affects: >=2.14.0
gotchaDo not confuse `allure-python-commons` with older, incompatible Allure plugins like `pytest-allure-adaptor`. `allure-python-commons` provides the core API, while integrations like `allure-pytest` handle framework-specific logic. Using both or mixing old and new versions can lead to import errors and unexpected behavior.
fix
Ensure you are using `allure-pytest` (or another official adapter) and `allure-python-commons` together, and uninstall any legacy `pytest-allure-adaptor` plugins. Keep all `allure-framework` related packages updated to compatible versions.
affects: all
gotchaCustom labels added via `@allure.label` might not display directly in the default Allure Report HTML view. These labels are primarily intended for advanced filtering in Allure TestOps or for custom report processing.
fix
For visible categorization in the report, use standard labels like `severity`, `epic`, `feature`, `story`, `tag` which have dedicated sections. If custom labels are required for display, consider custom report transformations or use Allure TestOps integration.
affects: all
gotchaUsing `allure-python-commons` alone will not generate an interactive HTML Allure Report. It provides the API for creating report data. To get a report, you must also install a specific Allure adapter for your test framework (e.g., `allure-pytest` for Pytest) and the separate Allure Report command-line tool (which requires Java to run).
fix
Install `allure-pytest` (or your framework's adapter) via `pip install allure-pytest` and the Allure Report CLI tool (e.g., via `brew install allure` or by downloading from GitHub and ensuring Java is installed). Then run your tests with the adapter and generate the report using `allure generate` or `allure serve`.
affects: all
breakingOlder versions of `allure-python-commons` (pre-2.x) had compatibility issues with newer Pytest versions (e.g., Pytest 3.2.0 and later), specifically concerning the location of internal classes like `XFail`, leading to import failures.
fix
Upgrade all `allure-python` related packages (`allure-python-commons`, `allure-pytest`, etc.) to their latest compatible versions with your Pytest installation. The 2.x series resolved many of these issues.
affects: <2.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'allure.constants'; 'allure' is not a package
The 'allure.constants' module does not exist in the current version of the Allure package.
fix
Replace 'from allure.constants import AttachmentType' with 'from allure import attachment_type'.
SyntaxError: invalid syntax
The code uses type hints, which are not supported in Python 2.7.
fix
Upgrade to Python 3.5 or higher to support type hints.
allure: command not found
This error occurs when the Allure command-line interface (CLI) is not installed or its executable is not added to the system's PATH environment variable, meaning the operating system cannot locate the 'allure' command to generate or serve reports.
fix
Install the Allure CLI by downloading it from the official Allure Report GitHub releases page or via a package manager (like Scoop on Windows, Homebrew on macOS, or apt/yum on Linux), then ensure its 'bin' directory is added to your system's PATH. For example, on Linux/macOS, you might add `export PATH=$PATH:/path/to/allure-commandline/bin` to your shell profile (.bashrc, .zshrc).
AttributeError: module 'pytest' has no attribute 'allure'
This typically happens when `allure-pytest` is either not correctly installed, or there's a version mismatch/conflict, or the user is trying to access Allure functionalities via `pytest.allure` which is an outdated or incorrect way to use the Allure API with `pytest`.
fix
Ensure `allure-pytest` is installed (`pip install allure-pytest`). If it's already installed, try upgrading it and `allure-python-commons` (`pip install --upgrade allure-pytest allure-python-commons`). Instead of `pytest.allure.attach.file`, use `allure.attach.file` after importing `allure` directly: `import allure`.
ModuleNotFoundError: No module named 'allure.constants' OR ImportError: No module named allure_commons.types
This error signifies that the import path for `AttachmentType` or similar constants has changed between different versions of Allure, particularly from Allure 1 to Allure 2, or that the incorrect module is being imported from within `allure-python-commons`.
fix
For modern Allure Python integrations (Allure 2 and above), import `AttachmentType` from `allure_commons.types`. Replace `from allure.constants import AttachmentType` with `from allure_commons.types import AttachmentType`.
Upgrade
Version history
2.16.0latest on PyPI
Audit
Dependencies

No dependency data recorded yet.

Agent activity
92 hits · last 30 days
node
10
ahrefsbot
3
seranking-bot
2
amazonbot
1
Resources