qapytest 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qapytest-0.2.0 → qapytest-0.3.0}/CHANGELOG.md +35 -1
- qapytest-0.3.0/NOTICE +23 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/PKG-INFO +105 -50
- {qapytest-0.2.0 → qapytest-0.3.0}/README.md +101 -49
- {qapytest-0.2.0 → qapytest-0.3.0}/THIRD_PARTY_NOTICES.txt +12 -1
- {qapytest-0.2.0 → qapytest-0.3.0}/demo.py +40 -1
- qapytest-0.3.0/docs/API.md +540 -0
- qapytest-0.3.0/docs/CLI.md +178 -0
- qapytest-0.3.0/licenses/faker.LICENSE +19 -0
- qapytest-0.3.0/licenses/playwright-python.LICENSE +203 -0
- qapytest-0.3.0/licenses/pytest-playwright.LICENSE +202 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/pyproject.toml +4 -2
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/__init__.py +3 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_client_http.py +14 -4
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_config_http.py +5 -2
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_redis.py +40 -2
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_report.py +13 -3
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_sql.py +3 -1
- {qapytest-0.2.0 → qapytest-0.3.0}/uv.lock +183 -1
- qapytest-0.2.0/docs/API.md +0 -279
- qapytest-0.2.0/docs/CLI.md +0 -87
- {qapytest-0.2.0 → qapytest-0.3.0}/.gitignore +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/.pre-commit-config.yaml +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/httpx.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/jinja2.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/jsonschema.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/pytest.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/python_dotenv.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/redis-py.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/licenses/sqlalchemy.LICENSE +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_assets/_log_tree.html.jinja2 +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_assets/report.html.jinja2 +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_assets/scripts.js +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_assets/styles.css +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_attach.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_config.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_internal.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_json_validation.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_plugin.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_soft_assert.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/_step.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/qapytest/py.typed +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_attach.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_graphql_client.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_http_client.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_integration.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_internal_functions.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_markers.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_redis_client.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_soft_assert.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_sql_client.py +0 -0
- {qapytest-0.2.0 → qapytest-0.3.0}/tests/test_step.py +0 -0
|
@@ -5,9 +5,30 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.0] - 2025-10-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- 🎭 **Playwright integration** - pytest-playwright support with cross-browser testing (Chromium, Firefox, WebKit)
|
|
13
|
+
- 🌐 **Browser automation** - video recording, screenshots, traces, and mobile device emulation
|
|
14
|
+
- 🎲 **Faker integration** - built-in test data generation
|
|
15
|
+
- 🏷️ **Logger naming** - added ability to provide custom names for client loggers
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- 📚 **Documentation updates** - CLI and API docs
|
|
20
|
+
- 📚 **Third-party notices** - added Playwright and Faker licenses
|
|
21
|
+
- 🔧 **Project structure** - enhanced with browser testing capabilities
|
|
22
|
+
- 🧪 **Demo examples** - enhanced demo.py with comprehensive test scenarios
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- 🔧 **Internal fixes** - resolved internal bugs and improved stability
|
|
27
|
+
|
|
8
28
|
## [0.2.0] - 2025-10-06
|
|
9
29
|
|
|
10
30
|
### 🔧 Refactoring
|
|
31
|
+
|
|
11
32
|
- **Refactored public methods** - updated SqlClient API structure
|
|
12
33
|
- **Updated documentation** - aligned with current SqlClient implementation
|
|
13
34
|
- **Fixed tests** - updated test cases to match current SqlClient implementation
|
|
@@ -15,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
36
|
## [0.1.6] - 2025-09-30
|
|
16
37
|
|
|
17
38
|
### Fixed
|
|
39
|
+
|
|
18
40
|
- 🔴 **RedisClient** - improved connection handling and management
|
|
19
41
|
- 🔧 **Configuration** - fixed Redis client configuration and connection parameters
|
|
20
42
|
- 🔇 **HTTP library logging** - suppressed verbose logging from httpx, httpcore, and urllib3 to WARNING level to reduce noise in test output
|
|
@@ -22,18 +44,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
44
|
## [0.1.5] - 2025-09-25
|
|
23
45
|
|
|
24
46
|
### Fixed
|
|
47
|
+
|
|
25
48
|
- 🔒 **HTTP request logging** - fixed data masking in HTTP request/response logging to properly sanitize sensitive information
|
|
26
49
|
- 🌐 **Response headers logging** - improved logging of response headers with enhanced data sanitization
|
|
27
50
|
|
|
28
51
|
## [0.1.4] - 2025-09-25
|
|
29
52
|
|
|
30
53
|
### Enhanced
|
|
54
|
+
|
|
31
55
|
- 🔒 **Sensitive data masking** - comprehensive masking for headers, JSON fields, and text patterns in HTTP/GraphQL clients
|
|
32
56
|
- 🌐 **HttpClient & GraphQLClient** - unified BaseHttpClient architecture with enhanced logging and data sanitization
|
|
33
57
|
- 📝 **Documentation** - updated API documentation with complete parameter descriptions and sensitive data masking features
|
|
34
58
|
- 🔗 **README links** - fixed GitHub documentation links to use absolute URLs
|
|
35
59
|
|
|
36
60
|
### Added
|
|
61
|
+
|
|
37
62
|
- 🛡️ **New configuration options** for HttpClient and GraphQLClient:
|
|
38
63
|
- `sensitive_headers` - set of header names to mask in logs
|
|
39
64
|
- `sensitive_json_fields` - set of JSON field names to mask
|
|
@@ -41,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
41
66
|
- `mask_sensitive_data` - toggle for sensitive data masking
|
|
42
67
|
|
|
43
68
|
### Fixed
|
|
69
|
+
|
|
44
70
|
- 🧪 **Test improvements** - enhanced test coverage for logging assertions and header sanitization
|
|
45
71
|
- 📊 **GraphQL client** - removed unnecessary mocks and improved test assertions
|
|
46
72
|
- 🔧 **Import organization** - refactored client imports for better maintainability
|
|
@@ -48,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
48
74
|
## [0.1.3] - 2025-09-24
|
|
49
75
|
|
|
50
76
|
### Fixed
|
|
77
|
+
|
|
51
78
|
- 🌐 **HTTP request logging** - improved logging format and sensitive data sanitization in HTTP requests/responses
|
|
52
79
|
- 📊 **GraphQL client** - enhanced logging and data masking capabilities for GraphQL operations
|
|
53
80
|
- 🧪 **Internal testing improvements** - updated test suite to align with current HttpClient and GraphQLClient implementations
|
|
@@ -55,11 +82,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
55
82
|
## [0.1.2] - 2025-09-22
|
|
56
83
|
|
|
57
84
|
### Fixed
|
|
85
|
+
|
|
58
86
|
- 🌐 **Unicode support in HTML reports** - fixed display of Cyrillic and other non-ASCII characters in parametrized test names
|
|
59
87
|
- 📊 **Parameter display** - test parameters with Unicode characters now show properly instead of escape sequences
|
|
60
88
|
- 🔧 **NodeID formatting** - improved Unicode handling in test identification strings
|
|
61
89
|
|
|
62
90
|
### Added
|
|
91
|
+
|
|
63
92
|
- ✅ **Unicode decoding functions** - added `decode_unicode_escapes()` utility for proper character rendering
|
|
64
93
|
- 📝 **Enhanced parameter parsing** - improved `parse_params_from_nodeid()` with Unicode escape sequence support
|
|
65
94
|
- 🧪 **Comprehensive tests** - added test coverage for Unicode handling functions
|
|
@@ -67,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
67
96
|
## [0.1.1] - 2025-09-19
|
|
68
97
|
|
|
69
98
|
### Changed
|
|
99
|
+
|
|
70
100
|
- 🔧 **Internal improvements** - enhanced project structure and configuration
|
|
71
101
|
- 📝 **Documentation updates** - improved README with badges and better formatting
|
|
72
102
|
- ⚙️ **Build configuration** - optimized pyproject.toml for PyPI publishing
|
|
@@ -76,6 +106,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
76
106
|
## [0.1.0] - 2025-09-19
|
|
77
107
|
|
|
78
108
|
### Added
|
|
109
|
+
|
|
79
110
|
- 🚀 **Initial release** of QaPyTest - powerful testing framework for QA engineers
|
|
80
111
|
- 📊 **HTML report generation** with customizable themes (light/dark/auto)
|
|
81
112
|
- 🎯 **Soft assertions** - collect multiple failures in single test run
|
|
@@ -92,6 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
92
123
|
- 📚 **Comprehensive documentation** - API reference and CLI guide
|
|
93
124
|
|
|
94
125
|
### Features
|
|
126
|
+
|
|
95
127
|
- Python 3.10+ support
|
|
96
128
|
- Pytest plugin architecture
|
|
97
129
|
- Self-contained HTML reports
|
|
@@ -99,6 +131,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
99
131
|
- Configurable attachment size limits
|
|
100
132
|
- Professional report styling with responsive design
|
|
101
133
|
|
|
134
|
+
[0.3.0]: https://github.com/o73k51i/qapytest/releases/tag/v0.3.0
|
|
135
|
+
[0.3.0]: https://github.com/o73k51i/qapytest/releases/tag/v0.3.0
|
|
102
136
|
[0.2.0]: https://github.com/o73k51i/qapytest/releases/tag/v0.2.0
|
|
103
137
|
[0.1.6]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.6
|
|
104
138
|
[0.1.5]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.5
|
|
@@ -106,4 +140,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
106
140
|
[0.1.3]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.3
|
|
107
141
|
[0.1.2]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.2
|
|
108
142
|
[0.1.1]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.1
|
|
109
|
-
[0.1.0]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.0
|
|
143
|
+
[0.1.0]: https://github.com/o73k51i/qapytest/releases/tag/v0.1.0
|
qapytest-0.3.0/NOTICE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
This project includes components licensed under the Apache License, Version 2.0.
|
|
2
|
+
|
|
3
|
+
Specifically:
|
|
4
|
+
|
|
5
|
+
- Playwright for Python
|
|
6
|
+
Copyright (c) Microsoft Corporation
|
|
7
|
+
Licensed under the Apache License, Version 2.0
|
|
8
|
+
https://github.com/microsoft/playwright-python
|
|
9
|
+
|
|
10
|
+
- pytest-playwright
|
|
11
|
+
Copyright (c) Microsoft Corporation
|
|
12
|
+
Licensed under the Apache License, Version 2.0
|
|
13
|
+
https://github.com/microsoft/playwright-pytest
|
|
14
|
+
|
|
15
|
+
You may obtain a copy of the Apache License at:
|
|
16
|
+
|
|
17
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
|
|
19
|
+
Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
See the License for the specific language governing permissions and
|
|
23
|
+
limitations under the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qapytest
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A powerful testing framework based on pytest, specifically designed for QA engineers
|
|
5
5
|
Project-URL: Homepage, https://github.com/o73k51i/qapytest
|
|
6
6
|
Project-URL: Repository, https://github.com/o73k51i/qapytest
|
|
@@ -29,6 +29,7 @@ License: MIT License
|
|
|
29
29
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
30
|
SOFTWARE.
|
|
31
31
|
License-File: LICENSE
|
|
32
|
+
License-File: NOTICE
|
|
32
33
|
Keywords: automation,graphql,http,pytest,qa,redis,soft-assert,sql,test,testing
|
|
33
34
|
Classifier: Development Status :: 4 - Beta
|
|
34
35
|
Classifier: Framework :: Pytest
|
|
@@ -42,9 +43,11 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
42
43
|
Classifier: Topic :: Software Development :: Quality Assurance
|
|
43
44
|
Classifier: Topic :: Software Development :: Testing
|
|
44
45
|
Requires-Python: <3.14,>=3.10
|
|
46
|
+
Requires-Dist: faker>=37.11.0
|
|
45
47
|
Requires-Dist: httpx>=0.28.1
|
|
46
48
|
Requires-Dist: jinja2>=3.1.6
|
|
47
49
|
Requires-Dist: jsonschema>=4.25.1
|
|
50
|
+
Requires-Dist: pytest-playwright>=0.7.1
|
|
48
51
|
Requires-Dist: pytest>=8.4.2
|
|
49
52
|
Requires-Dist: python-dotenv>=1.1.1
|
|
50
53
|
Requires-Dist: redis>=6.4.0
|
|
@@ -54,40 +57,53 @@ Description-Content-Type: text/markdown
|
|
|
54
57
|
# QaPyTest
|
|
55
58
|
|
|
56
59
|
[](https://pypi.org/project/qapytest/)
|
|
60
|
+
[](https://pepy.tech/projects/qapytest)
|
|
57
61
|
[](https://pypi.org/project/qapytest/)
|
|
58
62
|
[](https://github.com/o73k51i/qapytest/blob/main/LICENSE)
|
|
59
63
|
[](https://github.com/o73k51i/qapytest)
|
|
60
64
|
|
|
61
|
-
`QaPyTest` — a powerful testing framework based on pytest, specifically
|
|
62
|
-
Turn your ordinary tests into detailed, structured
|
|
65
|
+
`QaPyTest` — a powerful testing framework based on pytest, specifically
|
|
66
|
+
designed for QA engineers. Turn your ordinary tests into detailed, structured
|
|
67
|
+
reports with built-in HTTP, SQL, Redis and GraphQL clients.
|
|
63
68
|
|
|
64
|
-
🎯 **QA made for QA** — every feature is designed for real testing and
|
|
69
|
+
🎯 **QA made for QA** — every feature is designed for real testing and
|
|
70
|
+
debugging needs.
|
|
65
71
|
|
|
66
72
|
## ⚡ Why QaPyTest?
|
|
67
73
|
|
|
68
74
|
- **🚀 Ready to use:** Install → run → get a beautiful report
|
|
69
75
|
- **🔧 Built-in clients:** HTTP, SQL, Redis, GraphQL — all in one package
|
|
70
76
|
- **📊 Professional reports:** HTML reports with attachments and logs
|
|
71
|
-
- **🎯 Soft assertions:** Collect multiple failures in one run instead of
|
|
77
|
+
- **🎯 Soft assertions:** Collect multiple failures in one run instead of
|
|
78
|
+
stopping at the first
|
|
72
79
|
- **📝 Structured steps:** Make your tests self-documenting
|
|
73
80
|
- **🔍 Debugging friendly:** Full traceability of every action in the test
|
|
74
81
|
|
|
75
82
|
## ⚙️ Key features
|
|
76
83
|
|
|
77
84
|
- **HTML report generation:** simple report at `report.html`.
|
|
78
|
-
- **Soft assertions:** allow collecting multiple failures in a single run
|
|
79
|
-
|
|
85
|
+
- **Soft assertions:** allow collecting multiple failures in a single run
|
|
86
|
+
without immediately ending the test.
|
|
87
|
+
- **Advanced steps:** structured logging of test steps for better report
|
|
88
|
+
readability.
|
|
80
89
|
- **Attachments:** ability to add files, logs and screenshots to test reports.
|
|
81
90
|
- **HTTP client:** client for performing HTTP requests.
|
|
82
91
|
- **SQL client:** client for executing raw SQL queries.
|
|
83
92
|
- **Redis client:** client for working with Redis.
|
|
84
93
|
- **GraphQL client:** client for executing GraphQL requests.
|
|
85
|
-
- **
|
|
94
|
+
- **Browser automation:** seamless integration with pytest-playwright for
|
|
95
|
+
end-to-end web testing.
|
|
96
|
+
- **Test data generation:** built-in Faker support for creating realistic test
|
|
97
|
+
data.
|
|
98
|
+
- **JSON Schema validation:** function to validate API responses or test
|
|
99
|
+
artifacts with support for soft-assert and strict mode.
|
|
86
100
|
|
|
87
101
|
## 👥 Ideal for
|
|
88
102
|
|
|
89
|
-
- **QA Engineers** — automate testing of APIs, databases
|
|
90
|
-
|
|
103
|
+
- **QA Engineers** — automate testing of APIs, databases, web services and
|
|
104
|
+
browser interfaces
|
|
105
|
+
- **Test Automation specialists** — get a ready toolkit for comprehensive
|
|
106
|
+
testing including web automation
|
|
91
107
|
|
|
92
108
|
## 🚀 Quick start
|
|
93
109
|
|
|
@@ -100,27 +116,38 @@ pip install qapytest
|
|
|
100
116
|
### 2️⃣ Your first powerful test
|
|
101
117
|
|
|
102
118
|
```python
|
|
103
|
-
from qapytest import step, attach, soft_assert, HttpClient, SqlClient
|
|
119
|
+
from qapytest import step, attach, soft_assert, HttpClient, SqlClient, Faker
|
|
104
120
|
|
|
105
121
|
def test_comprehensive_api_validation():
|
|
122
|
+
fake = Faker()
|
|
123
|
+
|
|
124
|
+
# Generate realistic test data
|
|
125
|
+
user_data = {"name": fake.name(), "email": fake.email()}
|
|
126
|
+
|
|
106
127
|
# Structured steps for readability
|
|
107
128
|
with step('🌐 Testing API endpoint'):
|
|
108
129
|
client = HttpClient(base_url="https://api.example.com")
|
|
109
|
-
response = client.
|
|
110
|
-
assert response.status_code ==
|
|
111
|
-
|
|
130
|
+
response = client.post("/users", json=user_data)
|
|
131
|
+
assert response.status_code == 201
|
|
132
|
+
|
|
112
133
|
# Add artifacts for debugging
|
|
113
134
|
attach(response.text, 'api_response.json')
|
|
114
|
-
|
|
135
|
+
|
|
115
136
|
# Soft assertions - collect all failures
|
|
116
|
-
soft_assert(response.json()['id']
|
|
117
|
-
soft_assert(
|
|
118
|
-
|
|
137
|
+
soft_assert(response.json()['id'] > 0, 'User ID check')
|
|
138
|
+
soft_assert(
|
|
139
|
+
response.json()['email'] == user_data['email'],
|
|
140
|
+
'Email matches'
|
|
141
|
+
)
|
|
142
|
+
|
|
119
143
|
# Database integration
|
|
120
144
|
with step('🗄️ Validate data in DB'):
|
|
121
|
-
db = SqlClient("
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
db = SqlClient("sqlite:///:memory:")
|
|
146
|
+
user_db_data = db.fetch_data(
|
|
147
|
+
"SELECT * FROM users WHERE email = :email",
|
|
148
|
+
params={"email": user_data['email']}
|
|
149
|
+
)
|
|
150
|
+
assert len(user_db_data) == 1
|
|
124
151
|
```
|
|
125
152
|
|
|
126
153
|
### 3️⃣ Run with beautiful reports
|
|
@@ -133,36 +160,51 @@ pytest --report-html
|
|
|
133
160
|
## 🔌 Built-in clients — everything QA needs
|
|
134
161
|
|
|
135
162
|
### 🌐 HttpClient — HTTP testing on steroids
|
|
163
|
+
|
|
136
164
|
```python
|
|
137
|
-
client = HttpClient(base_url="https://api.example.com"
|
|
138
|
-
response = client.post("/auth/login", json={"
|
|
139
|
-
# Automatic logging of requests/responses + timing + headers
|
|
165
|
+
client = HttpClient(base_url="https://api.example.com")
|
|
166
|
+
response = client.post("/auth/login", json={"foo": "bar"})
|
|
140
167
|
```
|
|
141
168
|
|
|
142
|
-
###
|
|
169
|
+
### 📊 GraphQL client — Modern APIs with minimal effort
|
|
170
|
+
|
|
143
171
|
```python
|
|
144
|
-
|
|
145
|
-
|
|
172
|
+
gql = GraphQLClient("https://api.github.com/graphql")
|
|
173
|
+
result = gql.execute("query { viewer { foo } }")
|
|
146
174
|
```
|
|
147
175
|
|
|
148
|
-
###
|
|
176
|
+
### 🗄️ SqlClient — Direct DB access
|
|
177
|
+
|
|
149
178
|
```python
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
result = gql.execute("query { viewer { login } }")
|
|
179
|
+
db = SqlClient("sqlite:///:memory:")
|
|
180
|
+
users = db.fetch_data("SELECT foo FROM bar")
|
|
153
181
|
```
|
|
154
182
|
|
|
155
183
|
### 🔴 RedisClient — Enhanced Redis operations with logging
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
redis_client = RedisClient(host="localhost")
|
|
187
|
+
redis_client.set("foo", "bar")
|
|
188
|
+
foo = redis_client.get("foo")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 🎭 Browser automation — powered by Playwright
|
|
192
|
+
|
|
156
193
|
```python
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
194
|
+
def test_web_app(page):
|
|
195
|
+
fake = Faker()
|
|
196
|
+
# Navigate to login page
|
|
197
|
+
page.goto("https://example.com/login")
|
|
198
|
+
# Generate and fill test data
|
|
199
|
+
page.get_by_label("Username").fill(fake.user_name())
|
|
200
|
+
page.get_by_label("Password").fill(fake.password())
|
|
201
|
+
page.get_by_role("button", name="Log in").click()
|
|
161
202
|
```
|
|
162
203
|
|
|
163
204
|
## 🎛️ Core testing tools
|
|
164
205
|
|
|
165
206
|
### 📝 Structured steps
|
|
207
|
+
|
|
166
208
|
```python
|
|
167
209
|
with step('🔍 Check authorization'):
|
|
168
210
|
with step('Send login request'):
|
|
@@ -171,28 +213,37 @@ with step('🔍 Check authorization'):
|
|
|
171
213
|
assert "token" in response.json()
|
|
172
214
|
```
|
|
173
215
|
|
|
174
|
-
### 🎯 Soft Assertions — collect all failures
|
|
216
|
+
### 🎯 Soft Assertions — collect all failures
|
|
217
|
+
|
|
175
218
|
```python
|
|
176
|
-
soft_assert(user.id == 1,
|
|
177
|
-
soft_assert(user.active, '
|
|
178
|
-
soft_assert('admin' == user.roles, 'Access rights')
|
|
219
|
+
soft_assert(user.id == 1, "Check user ID")
|
|
220
|
+
soft_assert(user.active, 'Check status')
|
|
179
221
|
# The test will continue and show all failures together!
|
|
180
222
|
```
|
|
181
223
|
|
|
182
224
|
### 📎 Attachments — full context
|
|
225
|
+
|
|
183
226
|
```python
|
|
184
227
|
attach(response.json(), 'server response')
|
|
185
|
-
attach(screenshot_bytes, 'error page')
|
|
228
|
+
attach(screenshot_bytes, 'error page')
|
|
186
229
|
attach(content, 'application', mime='text/plain')
|
|
187
230
|
```
|
|
188
231
|
|
|
189
232
|
### ✅ JSON Schema validation
|
|
233
|
+
|
|
190
234
|
```python
|
|
191
235
|
# Strict validation — stop the test on schema validation error
|
|
192
236
|
validate_json(api_response, schema_path="user_schema.json", strict=True)
|
|
193
|
-
|
|
194
237
|
# Soft mode — collect all schema errors and continue test execution
|
|
195
|
-
validate_json(api_response, schema=user_schema
|
|
238
|
+
validate_json(api_response, schema=user_schema)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 🎲 Faker — Realistic test data generation
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
fake = Faker()
|
|
245
|
+
fake.text(max_nb_chars=200) # Random text
|
|
246
|
+
fake.random_int(min=1, max=100) # Random numbers
|
|
196
247
|
```
|
|
197
248
|
|
|
198
249
|
More about the API on the [documentation page](https://github.com/o73k51i/qapytest/blob/main/docs/API.md).
|
|
@@ -201,8 +252,10 @@ More about the API on the [documentation page](https://github.com/o73k51i/qapyte
|
|
|
201
252
|
|
|
202
253
|
QaPyTest also supports custom pytest markers to improve reporting:
|
|
203
254
|
|
|
204
|
-
- **`@pytest.mark.title("Custom Test Name")`** : sets a custom test name in
|
|
205
|
-
|
|
255
|
+
- **`@pytest.mark.title("Custom Test Name")`** : sets a custom test name in
|
|
256
|
+
the HTML report
|
|
257
|
+
- **`@pytest.mark.component("API", "Database")`** : adds component tags to
|
|
258
|
+
the test
|
|
206
259
|
|
|
207
260
|
### Example usage of markers
|
|
208
261
|
|
|
@@ -212,18 +265,20 @@ import pytest
|
|
|
212
265
|
@pytest.mark.title("User authorization check")
|
|
213
266
|
@pytest.mark.component("Auth", "API")
|
|
214
267
|
def test_user_login():
|
|
215
|
-
# test code
|
|
216
268
|
pass
|
|
217
269
|
```
|
|
218
270
|
|
|
219
271
|
## ⚙️ CLI options
|
|
220
272
|
|
|
221
|
-
- **`--env-file`** : path to an `.env` file with environment settings
|
|
222
|
-
|
|
223
|
-
- **`--
|
|
273
|
+
- **`--env-file`** : path to an `.env` file with environment settings
|
|
274
|
+
(default — `./.env`).
|
|
275
|
+
- **`--env-override`** : if set, values from the `.env` file will override
|
|
276
|
+
existing environment variables.
|
|
277
|
+
- **`--report-html [PATH]`** : create a self-contained HTML report; optionally
|
|
278
|
+
specify a path (default — `report.html`).
|
|
224
279
|
- **`--report-title NAME`** : set the HTML report title.
|
|
225
|
-
- **`--report-theme {light,dark,auto}`** : choose the report theme: `light`,
|
|
226
|
-
|
|
280
|
+
- **`--report-theme {light,dark,auto}`** : choose the report theme: `light`,
|
|
281
|
+
`dark` or `auto` (default).
|
|
227
282
|
|
|
228
283
|
More about CLI options on the [documentation page](https://github.com/o73k51i/qapytest/blob/main/docs/CLI.md).
|
|
229
284
|
|