Allure pytest integration
raw JSON → 2.15.3 verified Thu Apr 23 auth: no python install: verified
Allure pytest integration provides a way to integrate the Allure Test Reporting Framework with pytest tests. It functions as a pytest plugin, automatically collecting test results and generating comprehensive, interactive reports. The library is actively maintained as part of the `allure-python` monorepo, with frequent minor releases, typically on a monthly or bi-monthly basis.
pip install allure-pytest Common errors
error ModuleNotFoundError: No module named 'allure.constants' ↓
cause The 'allure.constants' module has been deprecated and removed in newer versions of allure-pytest.
fix
Replace 'from allure.constants import AttachmentType' with 'from allure import attachment_type'.
error AttributeError: module 'allure' has no attribute 'severity_level' ↓
cause The 'severity_level' attribute has been removed or renamed in recent versions of allure-pytest.
fix
Use 'from allure import severity_level' instead of 'allure.severity_level'.
error ModuleNotFoundError: No module named 'allure_commons' ↓
cause The 'allure_commons' module is not installed or not found in the Python environment.
fix
Install the module using 'pip install allure-python-commons'.
error AttributeError: 'str' object has no attribute 'iter_parents' ↓
cause Incompatibility between allure-pytest and pytest versions due to changes in pytest's internal APIs.
fix
Downgrade pytest to a compatible version, such as 'pytest==8.0.0'.
error SyntaxError: invalid syntax ↓
cause Attempting to run allure-pytest with an unsupported Python version, such as Python 2.7.
fix
Upgrade to Python 3.6 or higher to use allure-pytest.
Warnings
breaking Older versions of `allure-pytest` (pre-2.14.3) may not correctly handle `allure.title` for fixtures when used with `pytest` version 8.4 or later. ↓
fix Upgrade to `allure-pytest` version 2.14.3 or higher to ensure fixture titles are correctly displayed in reports.
gotcha If you were previously using `pytest-allure-adaptor`, it must be uninstalled before installing `allure-pytest` due to conflicting implementations. The `allure-pytest` setup process will explicitly check for this conflict. ↓
fix Run `pip uninstall pytest-allure-adaptor` before `pip install allure-pytest`.
breaking As of `allure-python` 2.14.0, official support for Python 3.7 has been dropped. Users on Python 3.7 will not receive updates or fixes for newer `allure-pytest` versions. ↓
fix Upgrade your Python environment to 3.8 or newer.
gotcha The Allure Report command-line tool (required to generate and serve HTML reports) is a separate installation from `allure-pytest` and requires a Java Runtime Environment (JRE) to function. ↓
fix Download and install the Allure command-line tool (e.g., via Homebrew on macOS, or manually) and ensure Java is installed and accessible in your PATH.
gotcha In versions prior to 2.15.0, reports for tests defined within nested classes might have incorrect `fullName`, `historyId`, `testCaseId`, and `subSuite` values, leading to improper grouping and history tracking. ↓
fix Upgrade to `allure-pytest` version 2.15.0 or higher for accurate reporting of nested test classes.
gotcha As of version 2.14.3, built-in (reserved) `pytest` markers are no longer converted into Allure tags. If your reporting workflow relied on these markers appearing as tags, this behavior has changed. ↓
fix Use explicit `allure.tag()` or `@allure.tag()` decorators for custom tags, or consider custom hooks if specific `pytest` markers still need to be mapped to Allure tags.
Install compatibility verified last tested: 2026-04-23
runtime status import time mem disk
3.10-alpine 0.07s 2.6MB 31.3M
3.10-slim 0.05s 2.6MB 32M
3.11-alpine 0.13s 2.9MB 34.3M
3.11-slim 0.10s 2.9MB 35M
3.12-alpine 0.10s 2.9MB 25.8M
3.12-slim 0.10s 2.9MB 26M
3.13-alpine 0.10s 3.1MB 25.5M
3.13-slim 0.10s 2.9MB 26M
3.9-alpine 0.07s 2.5MB 30.6M
3.9-slim 0.06s 2.5MB 31M
Imports
- allure
import allure - LabelType
from allure_commons.types import LabelType
Quickstart last tested: 2026-04-24
# test_example.py
import allure
import pytest
@allure.epic("Web Testing")
@allure.feature("Login Functionality")
def test_successful_login():
allure.dynamic.story("User can log in with valid credentials")
with allure.step("Enter username and password"):
print("Entering credentials...")
with allure.step("Click login button"):
print("Clicking login...")
assert True
@allure.epic("API Testing")
@allure.feature("User Management")
def test_get_user_profile():
allure.dynamic.story("Retrieve user data via API")
with allure.step("Send GET request to user endpoint"):
print("Sending request...")
with allure.step("Verify response status code"):
print("Checking status...")
with allure.step("Validate user data in response"):
print("Validating data...")
assert True
# To run tests and generate Allure results:
# pytest --alluredir=allure-results
# To serve the Allure report (requires Allure command-line tool):
# allure serve allure-results