# HG changeset patch # User Mads Kiilerich # Date 1548201378 -3600 # Node ID ffdcf0dfe0e4e67e33ae68a16d51a316833fdaff # Parent 53a07d06344be8645868968d05e634bb0f90aa0c tests: make test_admin_users user_and_repo_group_fail() fixture more stable When adding authentication_token() to log_user(), database session lifetime will in some cases change: test_admin_users test_delete_repo_group_err() use the user_and_repo_group_fail() fixture. Before, it got ObjectDeletedError when trying to delete a deleted RepoGroup and moved on. After changing log_user(), py.test would emit a warning: kallithea/tests/functional/test_admin_users.py::TestAdminUsersController::()::test_delete_repo_group_err .../site-packages/sqlalchemy/orm/persistence.py:1340: SAWarning: DELETE statement on table 'groups' expected to delete 1 row(s); 0 were matched. Please set confirm_deleted_rows=False within the mapper configuration to prevent this warning. % (table.description, expected, rows_matched) Instead, use RepoGroup.get_by_group_name to verify the group exists before trying to delete it. diff -r 53a07d06344b -r ffdcf0dfe0e4 kallithea/tests/functional/test_admin_users.py --- a/kallithea/tests/functional/test_admin_users.py Wed Jan 23 01:49:30 2019 +0100 +++ b/kallithea/tests/functional/test_admin_users.py Wed Jan 23 00:56:18 2019 +0100 @@ -18,7 +18,7 @@ from kallithea.tests.base import * from kallithea.tests.fixture import Fixture from kallithea.controllers.admin.users import UsersController -from kallithea.model.db import User, Permission, UserIpMap, UserApiKeys +from kallithea.model.db import User, Permission, UserIpMap, UserApiKeys, RepoGroup from kallithea.lib.auth import check_password from kallithea.model.user import UserModel from kallithea.model import validators @@ -39,11 +39,8 @@ repo_group = fixture.create_repo_group(name=groupname, cur_user=username) yield user, repo_group # cleanup - try: + if RepoGroup.get_by_group_name(groupname): fixture.destroy_repo_group(repo_group) - except ObjectDeletedError: - # delete already succeeded in test body - pass class TestAdminUsersController(TestController):