Skip to main content

A powerful testing framework based on pytest, specifically designed for QA engineers

Project description

QaPyTest

PyPI version PyPI Downloads Python versions License GitHub stars

QaPyTest โ€” a powerful testing framework based on pytest, specifically designed for QA engineers. Turn your ordinary tests into detailed, structured reports with built-in HTTP, SQL, Redis and GraphQL clients.

๐ŸŽฏ QA made for QA โ€” every feature is designed for real testing and debugging needs.

โšก Why QaPyTest?

  • ๐Ÿš€ Ready to use: Install โ†’ run โ†’ get a beautiful report
  • ๐Ÿ”ง Built-in clients: HTTP, SQL, Redis, GraphQL โ€” all in one package
  • ๐Ÿ“Š Professional reports: HTML reports with attachments and logs
  • ๐ŸŽฏ Soft assertions: Collect multiple failures in one run instead of stopping at the first
  • ๐Ÿ“ Structured steps: Make your tests self-documenting
  • ๐Ÿ” Debugging friendly: Full traceability of every action in the test

โš™๏ธ Key features

  • HTML report generation: simple report at report.html.
  • Soft assertions: allow collecting multiple failures in a single run without immediately ending the test.
  • Advanced steps: structured logging of test steps for better report readability.
  • Attachments: ability to add files, logs and screenshots to test reports.
  • HTTP client: client for performing HTTP requests.
  • SQL client: client for executing raw SQL queries.
  • Redis client: client for working with Redis.
  • GraphQL client: client for executing GraphQL requests.
  • Browser automation: seamless integration with pytest-playwright for end-to-end web testing.
  • Test data generation: built-in Faker support for creating realistic test data.
  • JSON Schema validation: function to validate API responses or test artifacts with support for soft-assert and strict mode.

๐Ÿ‘ฅ Ideal for

  • QA Engineers โ€” automate testing of APIs, databases, web services and browser interfaces
  • Test Automation specialists โ€” get a ready toolkit for comprehensive testing including web automation

๐Ÿš€ Quick start

1๏ธโƒฃ Installation

pip install qapytest

2๏ธโƒฃ Your first powerful test

from qapytest import step, attach, soft_assert, HttpClient, SqlClient, Faker

def test_comprehensive_api_validation():
    fake = Faker()

    # Generate realistic test data
    user_data = {"name": fake.name(), "email": fake.email()}

    # Structured steps for readability
    with step('๐ŸŒ Testing API endpoint'):
        client = HttpClient(base_url="https://api.example.com")
        response = client.post("/users", json=user_data)
        assert response.status_code == 201

    # Add artifacts for debugging
    attach(response.text, 'api_response.json')

    # Soft assertions - collect all failures
    soft_assert(response.json()['id'] > 0, 'User ID check')
    soft_assert(
      response.json()['email'] == user_data['email'],
      'Email matches'
    )

    # Database integration
    with step('๐Ÿ—„๏ธ Validate data in DB'):
        db = SqlClient("sqlite:///:memory:")
        user_db_data = db.fetch_data(
            "SELECT * FROM users WHERE email = :email",
            params={"email": user_data['email']}
        )
        assert len(user_db_data) == 1

3๏ธโƒฃ Run with beautiful reports

pytest --report-html
# Open report.html ๐ŸŽจ

๐Ÿ”Œ Built-in clients โ€” everything QA needs

๐ŸŒ HttpClient โ€” HTTP testing on steroids

client = HttpClient(base_url="https://api.example.com")
response = client.post("/auth/login", json={"foo": "bar"})

๐Ÿ“Š GraphQL client โ€” Modern APIs with minimal effort

gql = GraphQLClient("https://api.github.com/graphql")
result = gql.execute("query { viewer { foo } }")

๐Ÿ—„๏ธ SqlClient โ€” Direct DB access

db = SqlClient("sqlite:///:memory:")
users = db.fetch_data("SELECT foo FROM bar")

๐Ÿ”ด RedisClient โ€” Enhanced Redis operations with logging

redis_client = RedisClient(host="localhost")
redis_client.set("foo", "bar")
foo = redis_client.get("foo")

๐ŸŽญ Browser automation โ€” powered by Playwright

def test_web_app(page):
    fake = Faker()
    # Navigate to login page
    page.goto("https://example.com/login")
    # Generate and fill test data
    page.get_by_label("Username").fill(fake.user_name())
    page.get_by_label("Password").fill(fake.password())
    page.get_by_role("button", name="Log in").click()

๐ŸŽ›๏ธ Core testing tools

๐Ÿ“ Structured steps

with step('๐Ÿ” Check authorization'):
    with step('Send login request'):
        response = client.post("/login", json=creds)
    with step('Validate token'):
        assert "token" in response.json()

๐ŸŽฏ Soft Assertions โ€” collect all failures

soft_assert(user.id == 1, "Check user ID")
soft_assert(user.active, 'Check status')
# The test will continue and show all failures together!

๐Ÿ“Ž Attachments โ€” full context

attach(response.json(), 'server response')
attach(screenshot_bytes, 'error page')
attach(content, 'application', mime='text/plain')

โœ… JSON Schema validation

# Strict validation โ€” stop the test on schema validation error
validate_json(api_response, schema_path="user_schema.json", strict=True)
# Soft mode โ€” collect all schema errors and continue test execution
validate_json(api_response, schema=user_schema)

๐ŸŽฒ Faker โ€” Realistic test data generation

fake = Faker()
fake.text(max_nb_chars=200)  # Random text
fake.random_int(min=1, max=100)  # Random numbers

More about the API on the documentation page.

Test markers

QaPyTest also supports custom pytest markers to improve reporting:

  • @pytest.mark.title("Custom Test Name") : sets a custom test name in the HTML report
  • @pytest.mark.component("API", "Database") : adds component tags to the test

Example usage of markers

import pytest

@pytest.mark.title("User authorization check")
@pytest.mark.component("Auth", "API")
def test_user_login():
    pass

โš™๏ธ CLI options

  • --env-file : path to an .env file with environment settings (default โ€” ./.env).
  • --env-override : if set, values from the .env file will override existing environment variables.
  • --report-html [PATH] : create a self-contained HTML report; optionally specify a path (default โ€” report.html).
  • --report-title NAME : set the HTML report title.
  • --report-theme {light,dark,auto} : choose the report theme: light, dark or auto (default).

More about CLI options on the documentation page.

๐Ÿ“‘ License

This project is distributed under the license.

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

qapytest-0.3.0.tar.gz (118.0 kB view details)

Uploaded Source

Built Distribution

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

qapytest-0.3.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file qapytest-0.3.0.tar.gz.

File metadata

  • Download URL: qapytest-0.3.0.tar.gz
  • Upload date:
  • Size: 118.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for qapytest-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4489728e7feea4e9c7a1f0b8c130b11ef3b60d2bb0cec723785bfbcf8c1ccb66
MD5 140b8bede826426b12a9370cea6ddd2b
BLAKE2b-256 6c2bfd0bc79de5ce6a48c06af697f731124c08e2f36ef4f38da01f06e49fd87a

See more details on using hashes here.

File details

Details for the file qapytest-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: qapytest-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for qapytest-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 650937b311417475da583fcc4747be8b3b94ac4454fe3a1d64bc9382c4296ac4
MD5 4c1d7a26ab0473f403bd2371930ecd07
BLAKE2b-256 54029225e9611f48c40812530d04e2b4a0408711c62fdda2dd16f620fe8d12bf

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