Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kruton opened this issue Aug 5, 2024 · 0 comments

Comments

@kruton
Copy link

kruton commented Aug 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant