I have the project structure that looks like this
\project
\app.py
\tests
\__init__.py
\test_startup.py
app.py looks like this
from starlette.applications import Starlette
from starlette.responses import UJSONResponse
from starlette.routing import Route
async def homepage(request):
return UJSONResponse({'hello': 'world'})
app = Starlette(debug=True, routes=[
Route('/', homepage)
])
test_startup.py looks like this
from starlette.testclient import TestClient
from ..app import app
def test_app():
client = TestClient(app)
response = client.get('/')
assert response.status_code == 200
__init__.py is an empty file.
When I try to run pytest -v from my project directory it fails with the error
tests/test_startup.py:1: in <module>
from starlette.testclient import TestClient
E ModuleNotFoundError: No module named 'starlette'
I am able to run the application. Also I was trying to put conftest.py into both - tests and project folders and it did not help.
What is the problem?