qapytest


Nameqapytest JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA powerful testing framework based on pytest, specifically designed for QA engineers
upload_time2025-10-06 12:41:24
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10
licenseMIT License Copyright (c) 2025 o73k51i Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords automation graphql http pytest qa redis soft-assert sql test testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # QaPyTest

[![PyPI version](https://img.shields.io/pypi/v/qapytest.svg)](https://pypi.org/project/qapytest/)
[![Python versions](https://img.shields.io/pypi/pyversions/qapytest.svg)](https://pypi.org/project/qapytest/)
[![License](https://img.shields.io/github/license/o73k51i/qapytest.svg)](https://github.com/o73k51i/qapytest/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/o73k51i/qapytest.svg?style=social)](https://github.com/o73k51i/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.
- **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

```bash
pip install qapytest
```

### 2️⃣ Your first powerful test

```python
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

```bash
pytest --report-html
# Open report.html 🎨
```

## 🔌 Built-in clients — everything QA needs

### 🌐 HttpClient — HTTP testing on steroids
```python
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  
```python
db = SqlClient("postgresql://localhost/testdb")
users = db.fetch_data("SELECT * FROM users WHERE active = true")
```

### 📊 GraphQL client — Modern APIs with minimal effort
```python
gql = GraphQLClient("https://api.github.com/graphql", 
                   headers={"Authorization": "Bearer token"})
result = gql.execute("query { viewer { login } }")
```

### 🔴 RedisClient — Enhanced Redis operations with logging
```python
import json
redis_client = RedisClient(host="localhost", port=6379, db=0)
redis_client.set("session:123", json.dumps({"user_id": 1, "expires": "2024-01-01"}))
session_data = json.loads(redis_client.get("session:123"))
```

## 🎛️ Core testing tools

### 📝 Structured steps
```python
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  
```python
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
```python
attach(response.json(), 'server response')
attach(screenshot_bytes, 'error page') 
attach(content, 'application', mime='text/plain')
```

### ✅ JSON Schema validation
```python
# 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](https://github.com/o73k51i/qapytest/blob/main/docs/API.md).

## 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

```python
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 `.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).
- **`--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](https://github.com/o73k51i/qapytest/blob/main/docs/CLI.md).

## 📑 License

This project is distributed under the [license](https://github.com/o73k51i/qapytest/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "qapytest",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10",
    "maintainer_email": null,
    "keywords": "automation, graphql, http, pytest, qa, redis, soft-assert, sql, test, testing",
    "author": null,
    "author_email": "o73k51i <o73k51i@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/99/9a/ab1d9ef759f18a362cc2928bcc181bd6d0c7a637e12665eac372ff46b94f/qapytest-0.2.0.tar.gz",
    "platform": null,
    "description": "# QaPyTest\n\n[![PyPI version](https://img.shields.io/pypi/v/qapytest.svg)](https://pypi.org/project/qapytest/)\n[![Python versions](https://img.shields.io/pypi/pyversions/qapytest.svg)](https://pypi.org/project/qapytest/)\n[![License](https://img.shields.io/github/license/o73k51i/qapytest.svg)](https://github.com/o73k51i/qapytest/blob/main/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/o73k51i/qapytest.svg?style=social)](https://github.com/o73k51i/qapytest)\n\n`QaPyTest` \u2014 a powerful testing framework based on pytest, specifically designed for QA engineers.\nTurn your ordinary tests into detailed, structured reports with built-in HTTP, SQL, Redis and GraphQL clients.\n\n\ud83c\udfaf **QA made for QA** \u2014 every feature is designed for real testing and debugging needs.\n\n## \u26a1 Why QaPyTest?\n\n- **\ud83d\ude80 Ready to use:** Install \u2192 run \u2192 get a beautiful report\n- **\ud83d\udd27 Built-in clients:** HTTP, SQL, Redis, GraphQL \u2014 all in one package\n- **\ud83d\udcca Professional reports:** HTML reports with attachments and logs\n- **\ud83c\udfaf Soft assertions:** Collect multiple failures in one run instead of stopping at the first\n- **\ud83d\udcdd Structured steps:** Make your tests self-documenting\n- **\ud83d\udd0d Debugging friendly:** Full traceability of every action in the test\n\n## \u2699\ufe0f Key features\n\n- **HTML report generation:** simple report at `report.html`.\n- **Soft assertions:** allow collecting multiple failures in a single run without immediately ending the test.\n- **Advanced steps:** structured logging of test steps for better report readability.\n- **Attachments:** ability to add files, logs and screenshots to test reports.\n- **HTTP client:** client for performing HTTP requests.\n- **SQL client:** client for executing raw SQL queries.\n- **Redis client:** client for working with Redis.\n- **GraphQL client:** client for executing GraphQL requests.\n- **JSON Schema validation:** function to validate API responses or test artifacts with support for soft-assert and strict mode.\n\n## \ud83d\udc65 Ideal for\n\n- **QA Engineers** \u2014 automate testing of APIs, databases and web services\n- **Test Automation specialists** \u2014 get a ready toolkit for comprehensive testing\n\n## \ud83d\ude80 Quick start\n\n### 1\ufe0f\u20e3 Installation\n\n```bash\npip install qapytest\n```\n\n### 2\ufe0f\u20e3 Your first powerful test\n\n```python\nfrom qapytest import step, attach, soft_assert, HttpClient, SqlClient\n\ndef test_comprehensive_api_validation():\n    # Structured steps for readability\n    with step('\ud83c\udf10 Testing API endpoint'):\n        client = HttpClient(base_url=\"https://api.example.com\")\n        response = client.get(\"/users/1\")\n        assert response.status_code == 200\n    \n    # Add artifacts for debugging\n    attach(response.text, 'api_response.json')\n    \n    # Soft assertions - collect all failures\n    soft_assert(response.json()['id'] == 1, 'User ID check')\n    soft_assert(response.json()['active'], 'User is active')\n    \n    # Database integration\n    with step('\ud83d\uddc4\ufe0f Validate data in DB'):\n        db = SqlClient(\"postgresql://user:pass@localhost/db\")\n        user_data = db.fetch_data(\"SELECT * FROM users WHERE id = 1\")\n        assert len(user_data) == 1\n```\n\n### 3\ufe0f\u20e3 Run with beautiful reports\n\n```bash\npytest --report-html\n# Open report.html \ud83c\udfa8\n```\n\n## \ud83d\udd0c Built-in clients \u2014 everything QA needs\n\n### \ud83c\udf10 HttpClient \u2014 HTTP testing on steroids\n```python\nclient = HttpClient(base_url=\"https://api.example.com\", timeout=30)\nresponse = client.post(\"/auth/login\", json={\"username\": \"test\"})\n# Automatic logging of requests/responses + timing + headers\n```\n\n### \ud83d\uddc4\ufe0f SqlClient \u2014 Direct DB access  \n```python\ndb = SqlClient(\"postgresql://localhost/testdb\")\nusers = db.fetch_data(\"SELECT * FROM users WHERE active = true\")\n```\n\n### \ud83d\udcca GraphQL client \u2014 Modern APIs with minimal effort\n```python\ngql = GraphQLClient(\"https://api.github.com/graphql\", \n                   headers={\"Authorization\": \"Bearer token\"})\nresult = gql.execute(\"query { viewer { login } }\")\n```\n\n### \ud83d\udd34 RedisClient \u2014 Enhanced Redis operations with logging\n```python\nimport json\nredis_client = RedisClient(host=\"localhost\", port=6379, db=0)\nredis_client.set(\"session:123\", json.dumps({\"user_id\": 1, \"expires\": \"2024-01-01\"}))\nsession_data = json.loads(redis_client.get(\"session:123\"))\n```\n\n## \ud83c\udf9b\ufe0f Core testing tools\n\n### \ud83d\udcdd Structured steps\n```python\nwith step('\ud83d\udd0d Check authorization'):\n    with step('Send login request'):\n        response = client.post(\"/login\", json=creds)\n    with step('Validate token'):\n        assert \"token\" in response.json()\n```\n\n### \ud83c\udfaf Soft Assertions \u2014 collect all failures  \n```python\nsoft_assert(user.id == 1, 'User ID')\nsoft_assert(user.active, 'Active status')\nsoft_assert('admin' == user.roles, 'Access rights')\n# The test will continue and show all failures together!\n```\n\n### \ud83d\udcce Attachments \u2014 full context\n```python\nattach(response.json(), 'server response')\nattach(screenshot_bytes, 'error page') \nattach(content, 'application', mime='text/plain')\n```\n\n### \u2705 JSON Schema validation\n```python\n# Strict validation \u2014 stop the test on schema validation error\nvalidate_json(api_response, schema_path=\"user_schema.json\", strict=True)\n\n# Soft mode \u2014 collect all schema errors and continue test execution\nvalidate_json(api_response, schema=user_schema, strict=False)\n```\n\nMore about the API on the [documentation page](https://github.com/o73k51i/qapytest/blob/main/docs/API.md).\n\n## Test markers\n\nQaPyTest also supports custom pytest markers to improve reporting:\n\n- **`@pytest.mark.title(\"Custom Test Name\")`** : sets a custom test name in the HTML report\n- **`@pytest.mark.component(\"API\", \"Database\")`** : adds component tags to the test\n\n### Example usage of markers\n\n```python\nimport pytest\n\n@pytest.mark.title(\"User authorization check\")\n@pytest.mark.component(\"Auth\", \"API\")\ndef test_user_login():\n    # test code\n    pass\n```\n\n## \u2699\ufe0f CLI options\n\n- **`--env-file`** : path to an `.env` file with environment settings (default \u2014 `./.env`).\n- **`--env-override`** : if set, values from the `.env` file will override existing environment variables.\n- **`--report-html [PATH]`** : create a self-contained HTML report; optionally specify a path (default \u2014 `report.html`).\n- **`--report-title NAME`** : set the HTML report title.\n- **`--report-theme {light,dark,auto}`** : choose the report theme: `light`, `dark` or `auto` (default).\n- **`--max-attachment-bytes N`** : maximum size of an attachment (in bytes) that will be inlined in the HTML; larger files will be truncated.\n\nMore about CLI options on the [documentation page](https://github.com/o73k51i/qapytest/blob/main/docs/CLI.md).\n\n## \ud83d\udcd1 License\n\nThis project is distributed under the [license](https://github.com/o73k51i/qapytest/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 o73k51i  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A powerful testing framework based on pytest, specifically designed for QA engineers",
    "version": "0.2.0",
    "project_urls": {
        "Bug Reports": "https://github.com/o73k51i/qapytest/issues",
        "Documentation": "https://github.com/o73k51i/qapytest/blob/main/README.md",
        "Homepage": "https://github.com/o73k51i/qapytest",
        "Repository": "https://github.com/o73k51i/qapytest"
    },
    "split_keywords": [
        "automation",
        " graphql",
        " http",
        " pytest",
        " qa",
        " redis",
        " soft-assert",
        " sql",
        " test",
        " testing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "31e644c3ec998d44f231eb63809ae3ce8cca35b1fd1ca81b7eeda7372674c31a",
                "md5": "f17b29ddedc88d28bc47a0843f61f360",
                "sha256": "46707b5c8c9286ec2ba0ad28a8c11894744f6960ead64a09e42b302286fb485f"
            },
            "downloads": -1,
            "filename": "qapytest-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f17b29ddedc88d28bc47a0843f61f360",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 40993,
            "upload_time": "2025-10-06T12:41:22",
            "upload_time_iso_8601": "2025-10-06T12:41:22.654062Z",
            "url": "https://files.pythonhosted.org/packages/31/e6/44c3ec998d44f231eb63809ae3ce8cca35b1fd1ca81b7eeda7372674c31a/qapytest-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "999aab1d9ef759f18a362cc2928bcc181bd6d0c7a637e12665eac372ff46b94f",
                "md5": "d7f7663bb6676527560507ad8a5e6bb4",
                "sha256": "f626998c4ec62a88da40a2b7dbf05403534950b7c046b0d04bd25f6723d2069a"
            },
            "downloads": -1,
            "filename": "qapytest-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d7f7663bb6676527560507ad8a5e6bb4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10",
            "size": 101876,
            "upload_time": "2025-10-06T12:41:24",
            "upload_time_iso_8601": "2025-10-06T12:41:24.174711Z",
            "url": "https://files.pythonhosted.org/packages/99/9a/ab1d9ef759f18a362cc2928bcc181bd6d0c7a637e12665eac372ff46b94f/qapytest-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 12:41:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "o73k51i",
    "github_project": "qapytest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "qapytest"
}
        
Elapsed time: 1.73034s