diff --git a/kallithea/tests/__init__.py b/kallithea/tests/__init__.py --- a/kallithea/tests/__init__.py +++ b/kallithea/tests/__init__.py @@ -196,7 +196,7 @@ class BaseTestController(object): 'password': password}) if 'Invalid username or password' in response.body: - self.fail('could not login using %s %s' % (username, password)) + pytest.fail('could not login using %s %s' % (username, password)) self.assertEqual(response.status, '302 Found') self.assert_authenticated_user(response, username) @@ -219,14 +219,14 @@ class BaseTestController(object): def checkSessionFlash(self, response, msg=None, skip=0, _matcher=lambda msg, m: msg in m): if 'flash' not in response.session: - self.fail(safe_str(u'msg `%s` not found - session has no flash:\n%s' % (msg, response))) + pytest.fail(safe_str(u'msg `%s` not found - session has no flash:\n%s' % (msg, response))) try: level, m = response.session['flash'][-1 - skip] if _matcher(msg, m): return except IndexError: pass - self.fail(safe_str(u'msg `%s` not found in session flash (skipping %s): %s' % + pytest.fail(safe_str(u'msg `%s` not found in session flash (skipping %s): %s' % (msg, skip, ', '.join('`%s`' % m for level, m in response.session['flash'])))) diff --git a/kallithea/tests/functional/test_admin_repos.py b/kallithea/tests/functional/test_admin_repos.py --- a/kallithea/tests/functional/test_admin_repos.py +++ b/kallithea/tests/functional/test_admin_repos.py @@ -82,7 +82,7 @@ class _BaseTest(object): try: vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name))) except vcs.exceptions.VCSError: - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) RepoModel().delete(repo_name) Session().commit() @@ -136,7 +136,7 @@ class _BaseTest(object): except vcs.exceptions.VCSError: RepoGroupModel().delete(group_name) Session().commit() - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) RepoModel().delete(repo_name_full) RepoGroupModel().delete(group_name) @@ -228,7 +228,7 @@ class _BaseTest(object): except vcs.exceptions.VCSError: RepoGroupModel().delete(group_name) Session().commit() - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) RepoModel().delete(repo_name_full) RepoGroupModel().delete(group_name) @@ -285,7 +285,7 @@ class _BaseTest(object): except vcs.exceptions.VCSError: RepoGroupModel().delete(group_name) Session().commit() - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) #check if inherited permissiona are applied inherited_perms = UserRepoToPerm.query() \ @@ -360,7 +360,7 @@ class _BaseTest(object): try: vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name))) except vcs.exceptions.VCSError: - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) response = self.app.post(url('delete_repo', repo_name=repo_name), params={'_method': 'delete', '_authentication_token': self.authentication_token()}) @@ -413,7 +413,7 @@ class _BaseTest(object): try: vcs.get_repo(safe_str(os.path.join(TESTS_TMP_PATH, repo_name))) except vcs.exceptions.VCSError: - self.fail('no repo %s in filesystem' % repo_name) + pytest.fail('no repo %s in filesystem' % repo_name) response = self.app.post(url('delete_repo', repo_name=repo_name), params={'_method': 'delete', '_authentication_token': self.authentication_token()}) diff --git a/kallithea/tests/vcs/test_git.py b/kallithea/tests/vcs/test_git.py --- a/kallithea/tests/vcs/test_git.py +++ b/kallithea/tests/vcs/test_git.py @@ -4,6 +4,9 @@ import sys import mock import datetime import urllib2 + +import pytest + from kallithea.lib.vcs.backends.git import GitRepository, GitChangeset from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState @@ -17,7 +20,7 @@ class GitRepositoryTest(unittest.TestCas def __check_for_existing_repo(self): if os.path.exists(TEST_GIT_REPO_CLONE): - self.fail('Cannot test git clone repo as location %s already ' + pytest.fail('Cannot test git clone repo as location %s already ' 'exists. You should manually remove it first.' % TEST_GIT_REPO_CLONE) @@ -339,7 +342,7 @@ class GitChangesetTest(unittest.TestCase idx += 1 rev_id = self.repo.revisions[rev] if idx > limit: - self.fail("Exceeded limit already (getting revision %s, " + pytest.fail("Exceeded limit already (getting revision %s, " "there are %s total revisions, offset=%s, limit=%s)" % (rev_id, count, offset, limit)) self.assertEqual(changeset, self.repo.get_changeset(rev_id)) @@ -347,7 +350,7 @@ class GitChangesetTest(unittest.TestCase start = offset end = limit and offset + limit or None sliced = list(self.repo[start:end]) - self.failUnlessEqual(result, sliced, + pytest.failUnlessEqual(result, sliced, msg="Comparison failed for limit=%s, offset=%s" "(get_changeset returned: %s and sliced: %s" % (limit, offset, result, sliced)) diff --git a/kallithea/tests/vcs/test_hg.py b/kallithea/tests/vcs/test_hg.py --- a/kallithea/tests/vcs/test_hg.py +++ b/kallithea/tests/vcs/test_hg.py @@ -1,5 +1,8 @@ import os + +import pytest + from kallithea.lib.utils2 import safe_str from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError @@ -20,7 +23,7 @@ class MercurialRepositoryTest(unittest.T def __check_for_existing_repo(self): if os.path.exists(TEST_HG_REPO_CLONE): - self.fail('Cannot test mercurial clone repo as location %s already ' + pytest.fail('Cannot test mercurial clone repo as location %s already ' 'exists. You should manually remove it first.' % TEST_HG_REPO_CLONE) @@ -67,7 +70,7 @@ class MercurialRepositoryTest(unittest.T def test_pull(self): if os.path.exists(TEST_HG_REPO_PULL): - self.fail('Cannot test mercurial pull command as location %s ' + pytest.fail('Cannot test mercurial pull command as location %s ' 'already exists. You should manually remove it first' % TEST_HG_REPO_PULL) repo_new = MercurialRepository(TEST_HG_REPO_PULL, create=True) diff --git a/kallithea/tests/vcs/test_nodes.py b/kallithea/tests/vcs/test_nodes.py --- a/kallithea/tests/vcs/test_nodes.py +++ b/kallithea/tests/vcs/test_nodes.py @@ -76,7 +76,7 @@ class NodeBasicTest(unittest.TestCase): ''' def _test_trailing_slash(self, path): if not path.endswith('/'): - self.fail("Trailing slash tests needs paths to end with slash") + pytest.fail("Trailing slash tests needs paths to end with slash") for kind in NodeKind.FILE, NodeKind.DIR: self.assertRaises(NodeError, Node, path=path, kind=kind)