sanic-org / sanic-testing

Test clients for Sanic

Home Page:https://sanic.dev/en/plugins/sanic-testing/getting-started.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sanic app without any endpoints fails during routing

LiraNuna opened this issue · comments

import pytest
from sanic import Sanic
from sanic_testing import TestManager


@pytest.fixture
def app():
    sanic_app = Sanic(__name__)
    TestManager(sanic_app)

    return sanic_app


@pytest.mark.asyncio
async def test_not_found(app):
    request, response = await app.asgi_client.get("/not-a-known-endpoint")

    assert response.status == 404

This test will fail with an exception related to routing when ran.

This is true. Not related to sanic-testing though. A Sanic application MUST have at least one endpoint before it can be started.

I see. Thanks for confirming my suspicion. Closing.