Modern QA2026HTTP Method Enforcement — tiles
Log inJoin
36 / 65 · 14 API Testing Fundamentals · Error Handling and Environment Management← prev⊞ allnext →☰ Read as one page

5.5HTTP Method Enforcement

def test_unsupported_method(api):
    """Using an unsupported HTTP method should return 405."""
    r = api.request("PATCH", "/health")
    assert r.status_code in (404, 405)  # Not Found or Method Not Allowed

    r = api.request("DELETE", "/health")
    assert r.status_code in (404, 405)