Skip to main content

Qase Pytest Plugin for Qase TestOps and Qase Report

Project description

Qase TestOps Pytest Reporter

PyPI version PyPI downloads License

Qase Pytest Reporter enables seamless integration between your Pytest tests and Qase TestOps, providing automatic test result reporting, test case management, and comprehensive test analytics.

Features

  • Link automated tests to Qase test cases by ID
  • Auto-create test cases from your test code
  • Report test results with rich metadata (fields, attachments, steps)
  • Support for parameterized tests
  • Multi-project reporting support
  • Flexible configuration (file, environment variables, CLI)
  • Built-in support for Playwright-based tests

Installation

pip install qase-pytest

Quick Start

1. Create qase.config.json in your project root:

{
  "mode": "testops",
  "testops": {
    "project": "YOUR_PROJECT_CODE",
    "api": {
      "token": "YOUR_API_TOKEN"
    }
  }
}

2. Add Qase ID to your test:

from qase.pytest import qase

@qase.id(1)
def test_example():
    assert True

3. Run your tests:

pytest

Upgrading

For migration guides between major versions, see Upgrade Guide.

Configuration

The reporter is configured via (in order of priority):

  1. CLI options (--qase-*, highest priority)
  2. Environment variables (QASE_*)
  3. Config file (qase.config.json)

Minimal Configuration

Option Environment Variable CLI Option Description
mode QASE_MODE --qase-mode Set to testops to enable reporting
testops.project QASE_TESTOPS_PROJECT --qase-testops-project Your Qase project code
testops.api.token QASE_TESTOPS_API_TOKEN --qase-testops-api-token Your Qase API token

Example qase.config.json

{
  "mode": "testops",
  "fallback": "report",
  "testops": {
    "project": "YOUR_PROJECT_CODE",
    "api": {
      "token": "YOUR_API_TOKEN"
    },
    "run": {
      "title": "Pytest Automated Run"
    },
    "batch": {
      "size": 100
    }
  },
  "report": {
    "driver": "local",
    "connection": {
      "local": {
        "path": "./build/qase-report",
        "format": "json"
      }
    }
  },
  "framework": {
    "pytest": {
      "captureLogs": true
    }
  }
}

Full configuration reference: See qase-python-commons for all available options including logging, status mapping, execution plans, and more.

Usage

Link Tests with Test Cases

Associate your tests with Qase test cases using test case IDs:

from qase.pytest import qase

# Single ID
@qase.id(1)
def test_single_id():
    assert True

# Multiple IDs
@qase.id([2, 3])
def test_multiple_ids():
    assert True

Add Metadata

Enhance your tests with additional information:

from qase.pytest import qase

@qase.id(1)
@qase.title("User Login Test")
@qase.suite("Authentication")
@qase.fields(
    ("severity", "critical"),
    ("priority", "high"),
    ("layer", "e2e"),
    ("description", "Verify user can log in with valid credentials"),
    ("preconditions", "User account exists in the system"),
)
def test_user_login():
    assert True

Ignore Tests

Exclude specific tests from Qase reporting (test still runs, but results are not sent):

from qase.pytest import qase

@qase.ignore()
def test_not_reported():
    assert True

Test Result Statuses

Pytest Result Qase Status
Passed passed
Failed (AssertionError) failed
Failed (other exception) invalid
Skipped skipped

Attachments

Attach files, screenshots, and logs to test results:

from qase.pytest import qase

def test_with_attachments():
    # Attach file from path
    qase.attach("/path/to/file.txt")

    # Attach with custom MIME type
    qase.attach(("/path/to/file.json", "application/json"))

    # Attach content from memory
    qase.attach((b"screenshot data", "image/png", "screenshot.png"))

    assert True

Test Steps

Define test steps for detailed reporting:

from qase.pytest import qase

@qase.step("Open login page")
def open_login():
    pass

@qase.step("Enter credentials")
def enter_credentials(username, password):
    pass

def test_login():
    open_login()
    enter_credentials("user", "pass")

    # Inline step with context manager
    with qase.step("Click login button"):
        pass

For detailed usage examples, see the Usage Guide.

Running Tests

Basic Execution

pytest

With CLI Options

pytest \
    --qase-mode=testops \
    --qase-testops-project=PROJ \
    --qase-testops-api-token=your_token

With Environment Variables

export QASE_MODE=testops
export QASE_TESTOPS_PROJECT=PROJ
export QASE_TESTOPS_API_TOKEN=your_token
pytest

With Existing Test Run

pytest --qase-testops-run-id=123

With Test Plan

pytest --qase-testops-plan-id=456

Requirements

  • Python >= 3.9
  • pytest >= 7.0.0

Documentation

Guide Description
Usage Guide Complete usage reference with all decorators and options
Attachments Adding screenshots, logs, and files to test results
Steps Defining test steps for detailed reporting
Parameters Working with parameterized tests
Multi-Project Support Reporting to multiple Qase projects
Upgrade Guide Migration guide for breaking changes

Examples

See the examples directory for complete working examples.

License

Apache License 2.0. See LICENSE for details.

Project details


Release history Release notifications | RSS feed

This version

8.1.0

Download files

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

Source Distribution

qase_pytest-8.1.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

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

qase_pytest-8.1.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file qase_pytest-8.1.0.tar.gz.

File metadata

  • Download URL: qase_pytest-8.1.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qase_pytest-8.1.0.tar.gz
Algorithm Hash digest
SHA256 19386f1431177410847ca6c20f447ce19f313ddd17ae3dbe29e89ff7f626f223
MD5 8f35a6cf992bf9f993ab42f59732c6b1
BLAKE2b-256 69f98d85271e66e59cb8886817bf5bacf5ca645c5de991734105d6face49fa5d

See more details on using hashes here.

File details

Details for the file qase_pytest-8.1.0-py3-none-any.whl.

File metadata

  • Download URL: qase_pytest-8.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qase_pytest-8.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f19d18c369d0cb5662d6943b2255c176e94f901925e4b12655cd0ad59dbeb067
MD5 4b24d786dfb4d5194d677ac9890e1a42
BLAKE2b-256 c08caa31e0d3f5ccbfd381ce94531e0093b627c8b6322b02b3850bf221c42b0d

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