A powerful testing framework based on pytest, specifically designed for QA engineers
Project description
QaPyTest
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 with automatic JSON (de)serialization.
- GraphQL client: client for executing GraphQL requests.
- 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 and web services
- Test Automation specialists โ get a ready toolkit for comprehensive testing
๐ Quick start
1๏ธโฃ Installation
pip install qapytest
2๏ธโฃ Your first powerful test
from qapytest import step, attach, soft_assert, HttpClient, SqlClient
def test_comprehensive_api_validation():
# Structured steps for readability
with step('๐ Testing API endpoint'):
client = HttpClient(base_url="https://api.example.com")
response = client.get("/users/1")
assert response.status_code == 200
# Add artifacts for debugging
attach(response.text, 'api_response.json')
# Soft assertions - collect all failures
soft_assert(response.json()['id'] == 1, 'User ID check')
soft_assert(response.json()['active'], 'User is active')
# Database integration
with step('๐๏ธ Validate data in DB'):
db = SqlClient("postgresql://user:pass@localhost/db")
user_data = db.fetch_data("SELECT * FROM users WHERE id = 1")
assert len(user_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", timeout=30)
response = client.post("/auth/login", json={"username": "test"})
# Automatic logging of requests/responses + timing + headers
๐๏ธ SqlClient โ Direct DB access
db = SqlClient("postgresql://localhost/testdb")
users = db.fetch_data("SELECT * FROM users WHERE active = true")
db.execute_and_commit("UPDATE users SET last_login = NOW() WHERE id = 1")
๐ GraphQL client โ Modern APIs with minimal effort
gql = GraphQLClient("https://api.github.com/graphql",
headers={"Authorization": "Bearer token"})
result = gql.execute("query { viewer { login } }")
๐ด RedisClient โ Caching and sessions under control
redis = RedisClient(host="localhost", port=6379)
redis.set_value("session:123", {"user_id": 1, "expires": "2024-01-01"})
session_data = redis.get_value("session:123") # Automatic JSON serialization!
๐๏ธ 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, 'User ID')
soft_assert(user.active, 'Active status')
soft_assert('admin' == user.roles, 'Access rights')
# 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, strict=False)
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():
# test code
pass
โ๏ธ CLI options
--env-file: path to an.envfile with environment settings (default โ./.env).--env-override: if set, values from the.envfile 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,darkorauto(default).--max-attachment-bytes N: maximum size of an attachment (in bytes) that will be inlined in the HTML; larger files will be truncated.
More about CLI options on the documentation page.
๐ License
This project is distributed under the license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qapytest-0.1.0.tar.gz.
File metadata
- Download URL: qapytest-0.1.0.tar.gz
- Upload date:
- Size: 88.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14156b649b3071da0ea98e38285217b4064d90b165b5848793d6797577a8848b
|
|
| MD5 |
a1ac41d5fc3e8563fa5f8a50e77785bf
|
|
| BLAKE2b-256 |
cbfba70441d0769dc05a8b3929c9dc4e7672bcdd171395b857bc46c72de725a8
|
File details
Details for the file qapytest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qapytest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3bd0240b8a3a554c6a914dfe0fdb379de05aa5f2044d7ce054227dc39c3b790
|
|
| MD5 |
2acf7af7a70a81da2f65e1e562e70f17
|
|
| BLAKE2b-256 |
b0ef5694baa394ff5abce4d0a556fd6a37c4940d82bdc50f30af28cbab80cf81
|