pytest_toolkit
pytest_toolkit - is an useful utils for testing applications
how to use
- Installation
pip install pytest-toolkitpytest tests/ - Get started
The advantage is in having clear understanding of difference between response.json and static json. For example { 'Значение или тип элемента изменены': {"root['example1']": {'new_value': 'example2', 'old_value': 'example1'}} } == {} Its easy to see that value of key 'example1' changed from 'example1' to 'example2'.
ORfrom pytest_toolkit import get_diff def test(): response = client.get(url) assert get_diff(result_dict=response.json()) == {}from pytest_toolkit import get_file_json def test(): response = client.get(url) assert get_file_json() == response.json() - Static files search
1. You need to create static directory in tests/ 2. If you create filename test_a.py with test_b function, you need to create "a" directory in static directory and "b.json" in directory "a". Library will automatically find a file for get_diff function 3. If you don't have directory "a" in static files, library will try to find file "b.json" in "default" directory first If you don't want compare responses manually, you can use get_file_json function:from pytest_toolkit import get_file_json def test(): response = client.get(url) assert get_file_json() == {"test": "test"} - DOESNT_MATTER
1. If you don't care about value of dictionary, but you need a key, you can write "DOESNT_MATTER" in value and library will skip checking of this field. 2. If you need to have a constraint for value, you can write python code, for example "DOESNT_MATTER > 9" and library will check response.json() value is more than 9. - Check directory tests for more information and examples
- Coverage
---------- coverage: platform darwin, python 3.12.1-final-0 ---------- Name Stmts Miss Cover ------------------------------------------------- pytest_toolkit/__init__.py 2 0 100% pytest_toolkit/configure.py 9 0 100% pytest_toolkit/constants.py 5 0 100% pytest_toolkit/errors.py 2 0 100% pytest_toolkit/json.py 83 0 100% ------------------------------------------------- TOTAL 101 0 100%
Metadata
Release files for pytest-toolkit 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_toolkit-0.1.8.tar.gz | 5.7 kB | Details |
Release files / pytest_toolkit-0.1.8.tar.gz
| Download URL | pytest_toolkit-0.1.8.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ec1d404736e9a3b79d5fd7af18430c14b0f8a04cc1772d4699ba1ccae5fbc1e
|
|
BLAKE2b-256 checksum How to use checksums |
f26feadd788ca15fcca334f7d203914bca2b18d9f03bb15f5819f47db4579874
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|