sanic pytest
kobikun opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When I made a test code with pytest, First test_client.get() function was passed. but next test_client.get() function has a trouble
There is some error like this.
ERROR sanic.error:startup.py:960 Experienced exception while trying to serve
Traceback (most recent call last):
File "/py39//lib/python3.9/site-packages/sanic/mixins/startup.py", line 958, in serve_single
worker_serve(monitor_publisher=None, **kwargs)
File "/py39//lib/python3.9/site-packages/sanic/worker/serve.py", line 143, in worker_serve
raise e
File "/py39//lib/python3.9/site-packages/sanic/worker/serve.py", line 117, in worker_serve
return _serve_http_1(
File "/py39//lib/python3.9/site-packages/sanic/server/runners.py", line 222, in _serve_http_1
loop.run_until_complete(app._startup())
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/py39//lib/python3.9/site-packages/sanic/app.py", line 1729, in _startup
raise ServerError(message)
sanic.exceptions.ServerError: Duplicate route names detected: App.wrapped_handler. You should rename one or more of them explicitly by using the `name` param, or changing the implicit name derived from the class and function name. For more details, please see https://sanic.dev/en/guide/release-notes/v23.3.html#duplicated-route-names-are-no-longer-allowed
INFO sanic.root:startup.py:965 Server Stopped
sanic versions
sanic==23.6.0
sanic-compress==0.1.1
sanic-ext==23.6.0
sanic-jinja2==2022.11.11
sanic-routing==23.6.0
sanic-testing==23.6.0
Code snippet
import pytest
from was import webapp
from utils.logger import logger
@pytest.fixture
def app():
app = webapp.app
return app
def test_app_root(app):
_, response = app.test_client.get("/")
logger.info(response.status)
assert response.status == 200
_, response = app.test_client.get("/")
logger.info(response.status)
# assert request.method.lower() == "get"
assert response.status == 200
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
MacOS
Sanic Version
Sanic 23.6.0; Routing 23.6.0
Additional context
No response
I got good template codes
https://github.com/PacktPublishing/Python-Web-Development-with-Sanic/tree/main/Chapter09/testing4/tests