Skip to main content

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

Project description

Responses

https://travis-ci.org/dropbox/responses.png?branch=master

A utility library for mocking out the requests Python library.

import responses
import requests

@responses.activate
def test_my_api():
    responses.add(responses.GET, 'http://twitter.com/api/1/foobar',
                  body='{"error": "not found"}', status=404,
                  content_type='application/json')

    resp = requests.get('http://twitter.com/api/1/foobar')

    assert resp.json() == {"error": "not found"}

    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://twitter.com/api/1/foobar'
    assert responses.calls[0].response.content == '{"error": "not found"}'

License

Copyright 2013 Dropbox, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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

responses-0.2.0.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file responses-0.2.0.tar.gz.

File metadata

  • Download URL: responses-0.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for responses-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d0e390392838766a063d895ab197896f732a66778c6ee5e2fd17b7f5b3d2f5ce
MD5 2e9ce398d5de6ad9a43abe16d4d7ae06
BLAKE2b-256 4cf0f668807c0fcb799d0d360fc1d5c89fa4f559415f97bc7ab7e9d93ff4d17a

See more details on using hashes here.

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