pnuckowski / aioresponses

Aioresponses is a helper for mock/fake web requests in python aiohttp package.
MIT License
508 stars 86 forks source link

`aioresponses` drops empty query params #236

Open andmis opened 1 year ago

andmis commented 1 year ago
andrey@openai-andrey ~/tmp> cat mwe2.py
import asyncio
import aioresponses
import aiohttp

async def main():
    with aioresponses.aioresponses() as m:
        initial_url = "http://acme.com/concat?x="
        print(f"with aioresponses, initial_url: {initial_url}")
        m.post(initial_url)

        async with aiohttp.ClientSession() as session:
            async with session.post(url=initial_url) as response:
                final_url = response.url
                print(f"with aioresponses, final_url: {final_url}")

    initial_url = "http://acme.com/concat?x="
    print(f"without aioresponses, initial_url: {initial_url}")
    m.post(initial_url)

    async with aiohttp.ClientSession() as session:
        async with session.post(url=initial_url) as response:
            final_url = response.url
            print(f"without aioresponses, final_url: {final_url}")

asyncio.run(main())
andrey@openai-andrey ~/tmp> python mwe2.py
with aioresponses, initial_url: http://acme.com/concat?x=
with aioresponses, final_url: http://acme.com/concat
without aioresponses, initial_url: http://acme.com/concat?x=
without aioresponses, final_url: http://acme.com/concat?x=
andrey@openai-andrey ~/tmp>