Skip to main content

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):

Project details

Download files

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

Files for requests-testing, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size requests_testing-0.2.0-py2.py3-none-any.whl (6.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page