/ fastapi-template / tests / conftest.py
conftest.py
 1  from sqlalchemy.sql import Select
 2  from sqlalchemy.sql.expression import Delete
 3  from starlette.exceptions import HTTPException
 4  
 5  from api.app import app
 6  
 7  
 8  pytest_plugins = "tests.fixtures"
 9  
10  Select.__eq__ = Select.compare  # type: ignore
11  Delete.__eq__ = Delete.compare  # type: ignore
12  
13  del app.user_middleware[0]  # remove db session for tests
14  del app.exception_handlers[HTTPException]  # remove auto db rollback for tests
15  app.middleware_stack = app.build_middleware_stack()