MCPcopy
hub / github.com/encode/starlette / test_too_many_fields_raise

Function test_too_many_fields_raise

tests/test_formparsers.py:689–706  ·  view source on GitHub ↗
(
    app: ASGIApp,
    expectation: AbstractContextManager[Exception],
    test_client_factory: TestClientFactory,
)

Source from the content-addressed store, hash-verified

687 ],
688)
689def test_too_many_fields_raise(
690 app: ASGIApp,
691 expectation: AbstractContextManager[Exception],
692 test_client_factory: TestClientFactory,
693) -> None:
694 client = test_client_factory(app)
695 fields = []
696 for i in range(1001):
697 fields.append(f'--B\r\nContent-Disposition: form-data; name="N{i}";\r\n\r\n\r\n')
698 data = "".join(fields).encode("utf-8")
699 with expectation:
700 res = client.post(
701 "/",
702 data=data, # type: ignore
703 headers={"Content-Type": ("multipart/form-data; boundary=B")},
704 )
705 assert res.status_code == 400
706 assert res.text == "Too many fields. Maximum number of fields is 1000."
707
708
709@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
appendMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected