can someone provide a working example of a Sanic app including tests? The user guide (Getting Started | Sanic Framework) assigns the @pytest.fixture within the test script itself. Yet, obviously, my real app is not coded in the test script. My architecture looks like this:
... app = Sanic("my_app") ... app.run(host='0.0.0.0', port=3030, access_log=False, debug=False)
import pytest from sanic import Sanic, response from server import app def test_ping(app): request, response = app.test_client.get("/ping") assert request.method.lower() == "get" assert response.body == "pong" assert response.status == 200
I start the tests with pytest tests.py. Nothing happens. If I CTRL+C out, it says fixture ‘app’ not found. How can I connect both scripts?