Created
August 5, 2019 08:55
-
-
Save islishude/e8c14d9267af9c0dd14f60a6f20cad83 to your computer and use it in GitHub Desktop.
python requests mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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