Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Placebo is a tool for mocking external API's in python applications.

Project Description

Placebo is a utility that help mock api endpoints in a reusable and composable way.

To use placebo first we should create a placebo class for our mock. Placebo class represents a response for certain request. If url and http method of any request matches with mock, response that is described in placebo class will be return. We can create a placebo mock like this:

from placebo import Placebo

class UsersResponse(Placebo):
    url = ''
    body = json.dumps([{'name': 'Huseyin',
                        'last_name': 'Yilmaz'}])

Main interface for a placebo object is a decorator. Any function that decorated with a placebo class will be mocked with that placebo class.

def users_api_test(self):

You can decorate any function or method with this decorator. Even django views! This makes development against external apis very easy.

def users_list_view(request):

If your code is using multiple api endpoints you can easily stack placebo decorators on top of each other.

def test_valid_get_user(request):

def test_cannot_authenticate(request):

def test_api_is_not_available(request):

For more information, please refer to documentation

Release History

This version
History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(7.9 kB) Copy SHA256 Hash SHA256
Source None Aug 13, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate