-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bugdocumentationImprovements or additions to documentationImprovements or additions to documentation
Description
🐞 Describe the bug
In the Framework agnostic utilities section of the "Testing" docs, this code snippet indicates how to manually create a TestClient :
with loop_context() as loop:
app = _create_example_app()
with TestClient(TestServer(app), loop=loop) as client:
async def test_get_route():
nonlocal client
resp = await client.get("/")
assert resp.status == 200
text = await resp.text()
assert "Hello, world" in text
loop.run_until_complete(test_get_route())However, when trying to create a TestClient that way, you get the following error :
TypeError: Use async with instead
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fc6daa51a60>
I suspect the docs should rather indicate that the TestClient be created that way :
async with TestClient(TestServer(app), loop=loop) as client:
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugdocumentationImprovements or additions to documentationImprovements or additions to documentation