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!

A utility library for mocking out the `requests` Python library.

Project Description

A utility library for mocking out the requests Python library.

Starting with requests-testing

Here is a simple example:

import requests
import requests_testing

def example():
    requests_testing.add(request={'url': ''}, response={'body': 'ok'})
    resp = requests.get('')

    assert resp.text == 'ok'
    assert len(requests_testing.calls) == 1
    assert requests_testing.calls[0].request.url == ''

If your attempts to fetch a url which doesn’t hit a match, ConnectionError will raise:

import requests
import requests_testing

from requests.exceptions import ConnectionError

def test_error():
    with pytest.raises(ConnectionError):

Release History

This version
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
(6.8 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Nov 24, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting