Skip to content

Instantly share code, notes, and snippets.

@dcramer
Last active December 28, 2015 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcramer/7492965 to your computer and use it in GitHub Desktop.
Save dcramer/7492965 to your computer and use it in GitHub Desktop.
import responses

@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"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment