sanic-org / sanic-testing

Test clients for Sanic
https://sanic.dev/en/plugins/sanic-testing/getting-started.html
MIT License
31 stars 19 forks source link

Sanic app without any endpoints fails during routing #55

Closed LiraNuna closed 2 years ago

LiraNuna commented 2 years ago
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.

ahopkins commented 2 years ago

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

LiraNuna commented 2 years ago

I see. Thanks for confirming my suspicion. Closing.