Skip to content

Commit

Permalink
Add a test to demonstrate sending files via the test client
Browse files Browse the repository at this point in the history
This should ensure that it does work as expected.
  • Loading branch information
pgjones committed Apr 1, 2024
1 parent 4ccc1ea commit 1a65d32
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ async def echo() -> Response:
assert (await response.get_json()) == {"a": "b"}


async def test_files() -> None:
app = Quart(__name__)

@app.route("/", methods=["POST"])
async def echo() -> Response:
files = await request.files
data = files["file"].read()
return data

client = Client(app)
response = await client.post(
"/", files={"file": FileStorage(BytesIO(b"bar"), filename="a.txt")}
)
assert (await response.get_data(as_text=True)) == "bar"


async def test_data() -> None:
app = Quart(__name__)

Expand Down

0 comments on commit 1a65d32

Please sign in to comment.