Skip to content

Instantly share code, notes, and snippets.

@islishude
Created August 5, 2019 08:55
Show Gist options
  • Save islishude/e8c14d9267af9c0dd14f60a6f20cad83 to your computer and use it in GitHub Desktop.
Save islishude/e8c14d9267af9c0dd14f60a6f20cad83 to your computer and use it in GitHub Desktop.
python requests mock
import requests
import json
from httmock import HTTMock, response
def get_mock(*args, **kwarg):
content = json.dumps({"mock": "test"})
return response(status_code=200, content=content)
with HTTMock(get_mock):
resp = requests.get("http://api-mainnet.starteos.io/v1/chain/get_info")
print(resp.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment