Skip to content

Commit a773c2c

Browse files
committed
Refactor mock_database_service fixture to use yield for resource management
1 parent 1726289 commit a773c2c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/app/services/test_user_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
from prometheus.app.services.database_service import DatabaseService
44
from prometheus.app.services.user_service import UserService
5+
from tests.test_utils.fixtures import postgres_container_fixture # noqa: F401
56

67

78
@pytest.fixture
8-
def mock_database_service(postgres_container_fixture):
9+
def mock_database_service(postgres_container_fixture): # noqa: F811
910
service = DatabaseService(postgres_container_fixture.get_connection_url())
1011
service.start()
11-
return service
12+
yield service
13+
service.close()
1214

1315

1416
def test_create_superuser(mock_database_service):

0 commit comments

Comments
 (0)