# service.py
def print_my_object():
with db():
return x = models.MyObject().first()
print(x)
# test.py
def test_printing(test_db, # <- the fixture
test_object # <- loads the object into the db
):
retval = service.print_my_object
assert retval is not None
fails. The service is not a route. How do I get the test_db into the service during testing?
With the standard FastAPI test_db fixture, using
fails. The service is not a route. How do I get the
test_db
into the service during testing?