How to test response time in Request using Python Requests

HOME

import requests

endpoint = 'https://reqres.in/api/users'


def test_response():
    payload = {
        "name": "Vibha",
        "Job": "CEO"
    }

    response = requests.post(endpoint, payload)
    response_body = response.json()
    print("Response :", response_body)
    assert response.status_code == 201
    print("Elapsed Time :", response.elapsed.total_seconds())

pytest ResponseTime_test.py -s

Requests in Python

HOME