{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}