Test that we can r/w to a SpooledTemporaryFile managed by UploadFile before and after it rolls to disk
(max_size: int)
| 400 | @pytest.mark.anyio |
| 401 | @pytest.mark.parametrize(class="st">"max_size", [1, 1024], ids=[class="st">"rolled", class="st">"unrolled"]) |
| 402 | async def test_uploadfile_rolling(max_size: int) -> None: |
| 403 | class="st">"""Test that we can r/w to a SpooledTemporaryFile |
| 404 | managed by UploadFile before and after it rolls to disk |
| 405 | class="st">""" |
| 406 | stream: BinaryIO = SpooledTemporaryFile( class="cm"># type: ignore[assignment] |
| 407 | max_size=max_size |
| 408 | ) |
| 409 | file = UploadFile(filename=class="st">"file", file=stream, size=0) |
| 410 | assert await file.read() == bclass="st">"" |
| 411 | assert file.size == 0 |
| 412 | await file.write(bclass="st">"data") |
| 413 | assert await file.read() == bclass="st">"" |
| 414 | assert file.size == 4 |
| 415 | await file.seek(0) |
| 416 | assert await file.read() == bclass="st">"data" |
| 417 | await file.write(bclass="st">" more") |
| 418 | assert await file.read() == bclass="st">"" |
| 419 | assert file.size == 9 |
| 420 | await file.seek(0) |
| 421 | assert await file.read() == bclass="st">"data more" |
| 422 | assert file.size == 9 |
| 423 | await file.close() |
| 424 | |
| 425 | |
| 426 | def test_formdata() -> None: |
nothing calls this directly
no test coverage detected