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

Function test_too_many_fields_raise

tests/test_formparsers.py:689–706  ·  tests/test_formparsers.py::test_too_many_fields_raise
(
    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&class="cm">#x27;--B\r\nContent-Disposition: form-data; name=class="st">"N{i}";\r\n\r\n\r\n')
698 data = class="st">"".join(fields).encode(class="st">"utf-8")
699 with expectation:
700 res = client.post(
701 class="st">"/",
702 data=data, class="cm"># type: ignore
703 headers={class="st">"Content-Type": (class="st">"multipart/form-data; boundary=B")},
704 )
705 assert res.status_code == 400
706 assert res.text == class="st">"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