bash
pip install responses
python
import requests
import responses
def get_data_from_api():
response = requests.get('https://api.example.com/data')
return response.json()
@responses.activate
def test_get_data_from_api():
responses.add(responses.GET, 'https://api.example.com/data', json={'key': 'value'}, status=200)
data = get_data_from_api()
assert data == {'key': 'value'}
test_get_data_from_api()