CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-allure-pytest

Allure pytest integration that generates comprehensive test reports with rich metadata and visual test execution tracking

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

test-metadata.mddocs/

Test Metadata

Add rich metadata to tests using pytest markers for enhanced categorization, organization, and reporting in the Allure interface. This enables better test organization, filtering, and comprehensive test documentation.

Capabilities

Test Labels

Add categorical labels to tests for organization, filtering, and reporting purposes.

@pytest.mark.allure_label(*labels, label_type=str)
    """
    Add one or more labels of a specific type to a test.
    
    Parameters:
    - *labels: One or more label values
    - label_type: Type of label (severity, feature, story, epic, etc.)
    
    Usage:
    @pytest.mark.allure_label("critical", label_type="severity")
    @pytest.mark.allure_label("login", "logout", label_type="feature")
    """

Test Links

Associate tests with external resources like bug trackers, test management systems, or documentation.

@pytest.mark.allure_link(url, link_type=str, name=str)
    """
    Add a link to an external resource.
    
    Parameters:
    - url: Full URL or short reference (if link pattern configured)
    - link_type: Type of link ("issue", "tms", "test_case", etc.)  
    - name: Display name for the link
    
    Usage:
    @pytest.mark.allure_link("https://jira.example.com/PROJ-123", 
                           link_type="issue", name="Bug Report")
    @pytest.mark.allure_link("PROJ-123", link_type="issue", name="Bug Report")  # With pattern
    """

Test Descriptions

Add detailed descriptions to tests for better documentation and reporting.

@pytest.mark.allure_description(description)
    """
    Add a text description to a test.
    
    Parameters:
    - description: Text description of the test
    
    Note: Test docstrings are automatically used as descriptions if no marker is present.
    
    Usage:
    @pytest.mark.allure_description("Verify user authentication with valid credentials")
    """

@pytest.mark.allure_description_html(html_description)
    """
    Add an HTML description to a test.
    
    Parameters:
    - html_description: HTML formatted description
    
    Usage:
    @pytest.mark.allure_description_html("<h3>Test Steps</h3><ol><li>Login</li><li>Navigate</li></ol>")
    """

Standard Label Types

Severity Labels

import allure

@allure.severity(allure.severity_level.BLOCKER)    # Highest priority
@allure.severity(allure.severity_level.CRITICAL)   # High priority  
@allure.severity(allure.severity_level.NORMAL)     # Standard priority (default)
@allure.severity(allure.severity_level.MINOR)      # Low priority
@allure.severity(allure.severity_level.TRIVIAL)    # Lowest priority
def test_example():
    pass

BDD Labels

import allure

@allure.epic("E-commerce Platform")           # High-level business capability
@allure.feature("User Authentication")        # Product feature
@allure.story("User Login Process")          # User story
def test_user_login():
    pass

Test Organization Labels

import allure

@allure.suite("Authentication Tests")         # Test suite grouping
@allure.parent_suite("User Management")       # Parent suite grouping  
@allure.sub_suite("Login Functionality")      # Sub-suite grouping
def test_login_validation():
    pass

Usage Examples

Basic Metadata Assignment

import pytest
import allure

@pytest.mark.allure_label("critical", label_type="severity")
@pytest.mark.allure_label("authentication", label_type="feature")
@pytest.mark.allure_label("TC001", label_type="testId")
@pytest.mark.allure_link("PROJ-123", link_type="issue", name="Login Bug")
@pytest.mark.allure_description("Verify user can login with valid credentials")
def test_valid_login():
    """Test successful user authentication"""
    pass

Comprehensive Test Documentation

import pytest
import allure

@allure.severity(allure.severity_level.CRITICAL)
@allure.epic("User Management")
@allure.feature("Authentication")
@allure.story("User can login with valid credentials")
@allure.testcase("TC001", "Test Management System")
@allure.issue("PROJ-123", "Bug Tracker")
@pytest.mark.allure_description_html("""
<h3>Test Objective</h3>
<p>Verify that users can successfully authenticate with valid credentials</p>
<h3>Prerequisites</h3>
<ul>
    <li>User account exists</li>
    <li>Application is accessible</li>
</ul>
""")
def test_user_authentication():
    pass

Custom Label Categories

import pytest

@pytest.mark.allure_label("backend", label_type="component")
@pytest.mark.allure_label("database", label_type="layer") 
@pytest.mark.allure_label("regression", label_type="test_type")
@pytest.mark.allure_label("P1", label_type="priority")
@pytest.mark.allure_label("team_alpha", label_type="owner")
def test_database_connection():
    pass

Multiple Links and References

import pytest

@pytest.mark.allure_link("PROJ-123", link_type="issue", name="Original Bug")
@pytest.mark.allure_link("PROJ-456", link_type="issue", name="Related Issue")  
@pytest.mark.allure_link("TC001", link_type="tms", name="Test Case")
@pytest.mark.allure_link("https://wiki.company.com/auth", link_type="test_case", name="Documentation")
def test_authentication_flow():
    pass

Marker Constants

The plugin defines these marker names as constants:

ALLURE_LABEL_MARK = "allure_label"              # For @pytest.mark.allure_label
ALLURE_LINK_MARK = "allure_link"                # For @pytest.mark.allure_link  
ALLURE_DESCRIPTION_MARK = "allure_description"  # For @pytest.mark.allure_description
ALLURE_DESCRIPTION_HTML_MARK = "allure_description_html"  # For @pytest.mark.allure_description_html

Integration with Test Filtering

Labels added through markers can be used with command-line filtering options:

# Run tests with specific labels
pytest --allure-severities critical tests/
pytest --allure-features authentication tests/
pytest --allure-label component=backend tests/

Install with Tessl CLI

npx tessl i tessl/pypi-allure-pytest

docs

command-line.md

index.md

steps-attachments.md

test-filtering.md

test-metadata.md

tile.json