22 / 65 · 14 API Testing Fundamentals · Response Validation← prev⊞ allnext →☰ Read as one page
3.6Response Time Validation
def test_list_users_response_time(api):
r = api.get("/users")
assert r.elapsed.total_seconds() < 2.0, \
f"Response took {r.elapsed.total_seconds():.2f}s (limit: 2s)"
def test_health_check_fast(base_url):
r = requests.get(f"{base_url}/health")
assert r.elapsed.total_seconds() < 0.5