The companion pytest plugin for tiny-api-client
Project description
pytest-tiny-api-client
An official companion pytest plugin for the tiny-api-client library.
from my_api import MyClient
def test_my_client(api_call):
api_call.return_value = {"name": "Peter"}
user = MyClient().find_user(user_id=...)
assert user.name == "Peter"
One of the problems with testing functions that have been decorated is that decoration happens at import time, which means the decorators cannot be patched within each test without having to re-import the modules.
This plugin will patch these decorators at import time, and allow you to patch
the implementation during testing. To make this easier, this plugin exposes the
api_call fixture, which is a unittest.mock.Mock object which can be used to
test your endpoint methods with fake data.
For more details on how to use this fixture, check the documentation.
Installation
pip install pytest-tiny-api-client
Documentation
You can find the documentation at https://tiny-api-client.readthedocs.io
License
This software is distributed under the Lesser General Public License v2.1, more information available at the Free Software Foundation.
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 pytest-tiny-api-client-1.0.1.tar.gz.
File metadata
- Download URL: pytest-tiny-api-client-1.0.1.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
103d953a362f1cc83266d3cd27fa8eaa2d9c6fd05cf5cd5ef4947255b19931a6
|
|
| MD5 |
ac4599c1c6f9b3c871cb03fb559a6869
|
|
| BLAKE2b-256 |
5fe6b3a696b41771d358445a004f938d01f691f6644c459302f0a4d4d33cf195
|
File details
Details for the file pytest_tiny_api_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pytest_tiny_api_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa6be80ef3e7fec113b9604538aec24276c64cdf4fff11f30315d91fd97a70d
|
|
| MD5 |
ab0dd47fa3c32ef3f38089d9a8ed09ad
|
|
| BLAKE2b-256 |
0014083a5bc8d602a9cda19cfa26bfe97116b8f8e6039c9ef1e7bd1f202d4aa0
|