Skip to main content

The companion pytest plugin for tiny-api-client

Project description

pytest-tiny-api-client

License: GPL  v2

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

License: LGPL  v2.1

This software is distributed under the Lesser General Public License v2.1, more information available at the Free Software Foundation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-tiny-api-client-1.0.1.tar.gz (30.0 kB view hashes)

Uploaded Source

Built Distribution

pytest_tiny_api_client-1.0.1-py3-none-any.whl (13.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page