pallets / quart

An async Python micro framework for building web applications.
https://quart.palletsprojects.com
MIT License
2.95k stars 159 forks source link

Test client does not handle urls containing fragments correctly #363

Closed petrstefanueni closed 36 minutes ago

petrstefanueni commented 2 hours ago

Urls containing a fragment identifier e.g. /some-page#section are not handled correctly by the test client. This applies both if given as an argument (like in the example below) and when following a redirect response.

from quart import Quart
app = Quart(__name__)

@app.route('/')
async def hello():
    return 'hello'

async def test_get(app):
    client = app.test_client()
    response = await client.get('/')
    assert response.status_code == 200

async def test_get_with_fragment(app):
    client = app.test_client()
    response = await client.get('/#something')
    # status code is 404, so this fails
    assert response.status_code == 200

The second test fails because the returned status code is 404. The expected behavior is for both tests to pass.

Environment:

ThiefMaster commented 2 hours ago

Isn't passing a fragment there kind of a bug to begin with? Fragments are a purely client-side construct...