sanic
sanic copied to clipboard
Sanic-testing running asgi server doesn't work with sanic extentions
Describe the bug When trying to run an integration test with sanic-testing and sanic-extentions, the test fails with the following exception:
.venv/lib/python3.10/site-packages/httpx/_client.py:1842: in post
return await self.request(
.venv/lib/python3.10/site-packages/sanic_testing/testing.py:364: in request
await self.sanic_app._startup() # type: ignore
.venv/lib/python3.10/site-packages/sanic/app.py:1513: in _startup
self.ext._display()
.venv/lib/python3.10/site-packages/sanic_ext/bootstrap.py:110: in _display
f" > {extension.name} {extension.render_label()}"
.venv/lib/python3.10/site-packages/sanic_ext/extensions/base.py:56: in render_label
label = self.label()
.venv/lib/python3.10/site-packages/sanic_ext/extensions/openapi/extension.py:25: in label
return self._make_url()
.venv/lib/python3.10/site-packages/sanic_ext/extensions/openapi/extension.py:34: in _make_url
else self.app.serve_location
Without sanic-ext the test succeeds.
Code snippet
request, response = await app.asgi_client.post(
"/",
json={...},
)
Expected behavior The test does not fail
Environment (please complete the following information):
- OS: Ubuntu 22.04.1 LTS
- Python 3.10.4
- sanic 22.6.1
- sanic-testing: 22.6.0
- sanic-ext installed via sanic[ext]
Another piece of info: I'm using blueprints for the routes
Thanks for reporting. This is a known issue I will be pushing out a patch to v22.6 in the coming days: https://github.com/sanic-org/sanic/pull/2522/files