From 3f5ad3689c7a71f0c72c1f95c881285ca2ef9d9a Mon Sep 17 00:00:00 2001 From: Hemanth Thirthahalli Date: Thu, 13 Nov 2025 16:20:07 +0530 Subject: [PATCH] added testcases --- tests/test_datastructures.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py index 7e57d525c..f49fb431f 100644 --- a/tests/test_datastructures.py +++ b/tests/test_datastructures.py @@ -70,3 +70,16 @@ async def test_upload_file(): await file.seek(0) assert await file.read() == b"data and more data!" await file.close() + + +@pytest.mark.asyncio +async def test_uploadfile_read_text(tmp_path): + + file_path = tmp_path / "sample.txt" + file_path.write_text("Hello FastAPI!") + + with open(file_path, "rb") as f: + upload = UploadFile(filename="sample.txt", file=f) + content = await upload.read_text() + assert content == "Hello FastAPI!" + assert upload.filename == "sample.txt" # make sure .read_text() doesn't modify filename or headers \ No newline at end of file