{"id":1319,"library":"allure-python-commons","title":"allure-python-commons","description":"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.","status":"active","version":"2.15.3","language":"python","source_language":"en","source_url":"https://github.com/allure-framework/allure-python","tags":["testing","reporting","allure","test framework","api"],"install":[{"cmd":"pip install allure-python-commons","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The main entry point for Allure API functions like step, attach, and dynamic annotations.","symbol":"allure","correct":"import allure"},{"note":"Used for standardizing labels, e.g., allure.label(LabelType.SEVERITY, allure.severity_level.CRITICAL).","symbol":"LabelType","correct":"from allure_commons.types import LabelType"}],"quickstart":{"code":"import allure\nimport os\n\ndef my_function_with_steps():\n    with allure.step(\"Step 1: Perform initial setup\"):\n        print(\"Executing setup...\")\n        allure.attach(\"Setup log content\", name=\"setup_log\", attachment_type=allure.attachment_type.TEXT)\n\n    with allure.step(\"Step 2: Process data\"):\n        data = \"some_data_to_process\"\n        allure.dynamic.parameter(\"input_data\", data)\n        print(f\"Processing data: {data}\")\n        processed_data = data.upper()\n        allure.attach(processed_data, name=\"processed_output\", attachment_type=allure.attachment_type.TEXT)\n\n    with allure.step(\"Step 3: Final verification\"):\n        result = \"success\"\n        allure.dynamic.label(\"result\", result)\n        print(f\"Verification result: {result}\")\n\nif __name__ == \"__main__\":\n    # In a real test framework (e.g., pytest), this function would be a test.\n    # The Allure adapter would then capture these calls to build the report.\n    print(\"Running a simulated test function using allure-python-commons API.\")\n    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.\")\n    my_function_with_steps()\n    print(\"API calls made. Check the output directory configured by your Allure adapter.\")","lang":"python","description":"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."},"warnings":[{"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).","message":"Version 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.","severity":"breaking","affected_versions":">=2.14.0"},{"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.","message":"Do 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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"Custom 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.","severity":"gotcha","affected_versions":"all"},{"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`.","message":"Using `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).","severity":"gotcha","affected_versions":"all"},{"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.","message":"Older 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.","severity":"breaking","affected_versions":"<2.0.0"}],"env_vars":null,"search_vec":"'2.15.3':38 'activ':55 'adapt':27 'allur':2,6,26,61 'allure-python-common':1,5 'api':16,64 'build':25 'cadenc':44 'common':4,8 'core':11 'current':35 'develop':56 'end':19 'end-us':18 'ensur':54 'everi':49 'framework':32,63 'frequent':42 'functions/classes':23 'helper':22 'librari':13 'maintain':40 'minor/patch':47 'month':53 'multipl':46 'provid':14 'python':3,7,12,30 'releas':43,48 'report':60 'support':58 'test':31,59,62 'user':20 'various':29 'version':37 'week':51","created_at":"2026-04-09T03:42:49.613629+00:00","updated_at":"2026-04-15T20:01:35.360973+00:00","problems":[{"fix":"Replace 'from allure.constants import AttachmentType' with 'from allure import attachment_type'.","cause":"The 'allure.constants' module does not exist in the current version of the Allure package.","error":"ModuleNotFoundError: No module named 'allure.constants'; 'allure' is not a package"},{"fix":"Upgrade to Python 3.5 or higher to support type hints.","cause":"The code uses type hints, which are not supported in Python 2.7.","error":"SyntaxError: invalid syntax"},{"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).","cause":"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.","error":"allure: command not found"},{"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`.","cause":"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`.","error":"AttributeError: module 'pytest' has no attribute 'allure'"},{"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`.","cause":"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`.","error":"ModuleNotFoundError: No module named 'allure.constants' OR ImportError: No module named allure_commons.types"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.16.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://allurereport.org/","github":"https://github.com/allure-framework/allure-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/allure-python-commons/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":"verified"}}