Changeset - 769e86868c6c
[Not reviewed]
default
0 1 0
Konstantin Veretennicov - 9 years ago 2016-06-15 23:36:29
kveretennicov@gmail.com
tests: wrestle DetachedInstanceError out of create_test_user fixture
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/conftest.py
Show inline comments
 
@@ -9,7 +9,7 @@ from pylons.i18n.translation import _get
 
import pytest
 
from kallithea.model.user import UserModel
 
from kallithea.model.meta import Session
 
from kallithea.model.db import Setting
 
from kallithea.model.db import Setting, User
 

	
 

	
 
def pytest_configure():
 
@@ -41,14 +41,14 @@ def pytest_configure():
 
@pytest.yield_fixture
 
def create_test_user():
 
    """Provide users that automatically disappear after test is over."""
 
    test_users = []
 
    test_user_ids = []
 
    def _create_test_user(user_form):
 
        user = UserModel().create(user_form)
 
        test_users.append(user)
 
        test_user_ids.append(user.user_id)
 
        return user
 
    yield _create_test_user
 
    for user in test_users:
 
        UserModel().delete(user)
 
    for user_id in test_user_ids:
 
        UserModel().delete(user_id)
 
    Session().commit()
 

	
 

	
0 comments (0 inline, 0 general)