pallets / pallets/quart

Quart test client does not support same "data" arguments as Flask / Werkzeug

Open
#353 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
206
PR merge metrics
No merged PRs in 30d

Description

When migrating from Flask to Quart, one of the issues I ran into was that Werkzeug's client supports more in the data field. This input supports having a dict passed in which will encode it to a form and also allows values to be file data. If you look at Quart's test client, it only accepts pre-formatted data fields. It doesn't support passing in form-like data which is encoded. This is much less flexible than Flask / Werkzeug allowed and is making porting hundreds of tests a headache for this Flask project.

Here's an example of a snippet of tests:

async with aiofiles.open(filename, 'rb') as f:
    data = {
        'file_mapping': 'custom',
        'xlsx_file': (io.BytesIO(await f.read()), 'spreadsheet.xlsx')
    }

    res = await client.post(
        url_for("import_page"),
        data=data,
        follow_redirects=True,
    )

In Quart this results in something that is not parseable on the server side.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in quart/testing/utils.py around the test client's data handling, then compare it with the linked Werkzeug client behavior. Done means the client accepts form-like dictionaries, including file data, and produces a request the server can parse for the provided example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.