Skip to main content

AI-Powered Test Intelligence SDK for Python - pytest plugin with automatic failure analysis

Project description

QAagentic Python SDK

AI-Powered Test Intelligence for Python

PyPI version Python versions License


🚀 Installation

pip install qagentic-pytest

⚡ Quick Start

Zero-Config Setup

# conftest.py - That's it! QAagentic auto-hooks into pytest
import qagentic
# Run tests with QAagentic reporting
pytest --qagentic

With Configuration

# conftest.py
import qagentic

qagentic.configure(
    project_name="my-awesome-project",
    api_url="http://localhost:8080",
    api_key="your-api-key",  # Optional
)

📝 Usage Examples

Decorators (Allure-Compatible)

import qagentic
from qagentic import feature, story, severity, Severity, step

@feature("User Authentication")
@story("Login Flow")
@severity(Severity.CRITICAL)
def test_user_login():
    with step("Navigate to login page"):
        # Your test code
        pass
    
    with step("Enter credentials"):
        qagentic.attach_screenshot("login.png")
        # Your test code
        pass
    
    with step("Verify successful login"):
        # Your test code
        pass

All Available Decorators

from qagentic import (
    feature,      # Group by feature
    story,        # Group by user story
    epic,         # Group by epic
    severity,     # Set test severity
    tag,          # Add tags
    label,        # Custom labels
    link,         # Add links
    issue,        # Link to issue tracker
    testcase,     # Link to test management
    description,  # Add description
    title,        # Custom title
    owner,        # Test owner
    layer,        # Test layer (unit, integration, e2e)
    suite,        # Suite name
    sub_suite,    # Sub-suite name
    parent_suite, # Parent suite name
)

@epic("E-Commerce Platform")
@feature("Shopping Cart")
@story("Add to Cart")
@severity(Severity.CRITICAL)
@tag("smoke", "regression")
@owner("john.doe@example.com")
@issue("JIRA-123")
@testcase("TC-456")
@description("""
This test verifies the add to cart functionality:
1. Navigate to product page
2. Click add to cart
3. Verify cart updated
""")
def test_add_to_cart():
    pass

Steps with Context Manager

from qagentic import step

def test_checkout_flow():
    with step("Add items to cart") as s:
        s.attach_json({"item_id": "123", "quantity": 2}, "Cart Data")
        # Add items
    
    with step("Enter shipping info"):
        # Enter shipping
        pass
    
    with step("Complete payment") as s:
        s.set_parameter("payment_method", "credit_card")
        # Process payment

Attachments

import qagentic

def test_with_attachments():
    # Attach screenshot
    qagentic.attach_screenshot("path/to/screenshot.png", "Login Page")
    
    # Attach JSON data
    qagentic.attach_json({"status": "success"}, "API Response")
    
    # Attach text
    qagentic.attach_text("Log output here...", "Console Logs")
    
    # Attach HTML
    qagentic.attach_html("<h1>Report</h1>", "HTML Report")
    
    # Attach any file
    qagentic.attach_file("path/to/file.pdf", "PDF Report")
    
    # Attach video recording
    qagentic.attach_video("path/to/recording.mp4", "Test Recording")

Severity Levels

from qagentic import severity, Severity

@severity(Severity.BLOCKER)   # System unusable
def test_critical_path(): pass

@severity(Severity.CRITICAL)  # Major feature broken
def test_payment(): pass

@severity(Severity.NORMAL)    # Default severity
def test_feature(): pass

@severity(Severity.MINOR)     # Minor issue
def test_edge_case(): pass

@severity(Severity.TRIVIAL)   # Cosmetic issue
def test_ui_alignment(): pass

⚙️ Configuration

Command Line Options

pytest --qagentic                          # Enable QAagentic
pytest --qagentic-project=my-project       # Set project name
pytest --qagentic-api-url=http://api.com   # Set API URL
pytest --qagentic-api-key=secret           # Set API key
pytest --qagentic-output-dir=./results     # Set output directory
pytest --qagentic-no-console               # Disable console output
pytest --qagentic-no-api                   # Disable API reporting
pytest --qagentic-no-local                 # Disable local files

Environment Variables

export QAGENTIC_PROJECT_NAME=my-project
export QAGENTIC_API_URL=http://localhost:8080
export QAGENTIC_API_KEY=your-api-key
export QAGENTIC_OUTPUT_DIR=./qagentic-results
export QAGENTIC_AI_ANALYSIS=true
export QAGENTIC_SCREENSHOTS=on_failure

Configuration File

# qagentic.yaml
project:
  name: my-project
  environment: staging

reporting:
  api:
    enabled: true
    url: http://localhost:8080
    key: ${QAGENTIC_API_KEY}
  local:
    enabled: true
    output_dir: ./qagentic-results
    formats:
      - json
      - html
      - junit

features:
  ai_analysis: true
  failure_clustering: true
  flaky_detection: true
  screenshots: on_failure
  videos: on_failure

labels:
  team: platform
  component: auth

Programmatic Configuration

import qagentic

qagentic.configure(
    project_name="my-project",
    environment="staging",
    api_url="http://localhost:8080",
    api_key="your-api-key",
    output_dir="./qagentic-results",
    ai_analysis=True,
    screenshots="on_failure",
)

📊 Output Formats

JSON Report

{
  "id": "run_20231219_143022",
  "project_name": "my-project",
  "total": 100,
  "passed": 95,
  "failed": 3,
  "skipped": 2,
  "pass_rate": 95.0,
  "tests": [...]
}

JUnit XML (CI/CD Compatible)

<?xml version="1.0" ?>
<testsuite name="my-project" tests="100" failures="3" errors="0" skipped="2">
  <testcase name="test_login" classname="tests.test_auth" time="1.234"/>
  ...
</testsuite>

🔌 CI/CD Integration

GitHub Actions

- name: Run Tests
  run: pytest --qagentic
  env:
    QAGENTIC_API_URL: ${{ secrets.QAGENTIC_API_URL }}
    QAGENTIC_API_KEY: ${{ secrets.QAGENTIC_API_KEY }}

- name: Upload Results
  uses: actions/upload-artifact@v3
  if: always()
  with:
    name: qagentic-results
    path: qagentic-results/

GitLab CI

test:
  script:
    - pytest --qagentic
  artifacts:
    when: always
    paths:
      - qagentic-results/
    reports:
      junit: qagentic-results/junit.xml

🧠 AI Features

When connected to QAagentic server:

  • Automatic Root Cause Analysis - AI analyzes failures
  • Failure Clustering - Groups similar failures
  • Flaky Test Detection - Identifies unstable tests
  • Trend Analysis - Tracks quality over time
  • Smart Recommendations - Actionable fix suggestions

📚 API Reference

Core Functions

Function Description
qagentic.configure() Configure the SDK
qagentic.step() Create a test step
qagentic.attach() Attach data to test
qagentic.attach_screenshot() Attach screenshot
qagentic.attach_json() Attach JSON data

Decorators

Decorator Description
@feature(name) Group by feature
@story(name) Group by user story
@severity(level) Set severity level
@tag(*tags) Add tags
@label(name, value) Add custom label

🤝 Contributing

See CONTRIBUTING.md for guidelines.

📄 License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qagentic_pytest-0.1.4.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qagentic_pytest-0.1.4-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file qagentic_pytest-0.1.4.tar.gz.

File metadata

  • Download URL: qagentic_pytest-0.1.4.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for qagentic_pytest-0.1.4.tar.gz
Algorithm Hash digest
SHA256 5aa6660710b0dac97baab2f48ebc14f25cf98e98efd01ca1d4ffb53b2d8dfeac
MD5 3e34963db931f6f00ccfc0516d1b31b5
BLAKE2b-256 565f2f448c94e27412f6c37234ee4cf5ed457ee6f2e4cdc66c3079b30000d148

See more details on using hashes here.

File details

Details for the file qagentic_pytest-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for qagentic_pytest-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4564366ff213d0ca3d256b840d1cb14012825cf5979fa4bc6c472b7ae8f66304
MD5 3fa0b5a9521a9b1b6d279ca040e4f08e
BLAKE2b-256 ed64de9ad586cceba99e4b06eade56208d796db2793f0dbb100aa9b0ccd4253d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page