fixed connection closing issues in fixtures
This commit is contained in:
9
tests/fixtures/auth_fixtures.py
vendored
9
tests/fixtures/auth_fixtures.py
vendored
@@ -28,6 +28,9 @@ def test_user(db, auth_manager):
|
||||
db.add(user)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
# Expunge user from session to prevent ResourceWarning about unclosed connections
|
||||
# This detaches the object from the session so it doesn't hold a reference
|
||||
db.expunge(user)
|
||||
return user
|
||||
|
||||
|
||||
@@ -46,6 +49,8 @@ def test_admin(db, auth_manager):
|
||||
db.add(admin)
|
||||
db.commit()
|
||||
db.refresh(admin)
|
||||
# Expunge admin from session to prevent ResourceWarning about unclosed connections
|
||||
db.expunge(admin)
|
||||
return admin
|
||||
|
||||
@pytest.fixture
|
||||
@@ -63,6 +68,8 @@ def another_admin(db, auth_manager):
|
||||
db.add(admin)
|
||||
db.commit()
|
||||
db.refresh(admin)
|
||||
# Expunge admin from session to prevent ResourceWarning about unclosed connections
|
||||
db.expunge(admin)
|
||||
return admin
|
||||
|
||||
@pytest.fixture
|
||||
@@ -80,6 +87,8 @@ def other_user(db, auth_manager):
|
||||
db.add(user)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
# Expunge user from session to prevent ResourceWarning about unclosed connections
|
||||
db.expunge(user)
|
||||
return user
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user