(test_client_factory: TestClientFactory)
| 338 | |
| 339 | |
| 340 | def test_request_cookies(test_client_factory: TestClientFactory) -> None: |
| 341 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 342 | request = Request(scope, receive) |
| 343 | mycookie = request.cookies.get(class="st">"mycookie") |
| 344 | if mycookie: |
| 345 | response = Response(mycookie, media_type=class="st">"text/plain") |
| 346 | else: |
| 347 | response = Response(class="st">"Hello, world!", media_type=class="st">"text/plain") |
| 348 | response.set_cookie(class="st">"mycookie", class="st">"Hello, cookies!") |
| 349 | |
| 350 | await response(scope, receive, send) |
| 351 | |
| 352 | client = test_client_factory(app) |
| 353 | response = client.get(class="st">"/") |
| 354 | assert response.text == class="st">"Hello, world!" |
| 355 | response = client.get(class="st">"/") |
| 356 | assert response.text == class="st">"Hello, cookies!" |
| 357 | |
| 358 | |
| 359 | def test_cookie_lenient_parsing(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected