dependencies: bumped test libraries.

This commit is contained in:
Marcin Kuzminski 2019-09-30 13:26:57 +02:00
parent 81e1ecf4db
commit ed0653712b
9 changed files with 199 additions and 153 deletions

View file

@ -311,11 +311,11 @@ self: super: {
};
};
"coverage" = super.buildPythonPackage {
name = "coverage-4.5.3";
name = "coverage-4.5.4";
doCheck = false;
src = fetchurl {
url = "https://files.pythonhosted.org/packages/82/70/2280b5b29a0352519bb95ab0ef1ea942d40466ca71c53a2085bdeff7b0eb/coverage-4.5.3.tar.gz";
sha256 = "02f6m073qdispn96rc616hg0rnmw1pgqzw3bgxwiwza4zf9hirlx";
url = "https://files.pythonhosted.org/packages/85/d5/818d0e603685c4a613d56f065a721013e942088047ff1027a632948bdae6/coverage-4.5.4.tar.gz";
sha256 = "0p0j4di6h8k6ica7jwwj09azdcg4ycxq60i9qsskmsg94cd9yzg0";
};
meta = {
license = [ pkgs.lib.licenses.asl20 ];
@ -961,14 +961,18 @@ self: super: {
};
};
"mock" = super.buildPythonPackage {
name = "mock-1.0.1";
name = "mock-3.0.5";
doCheck = false;
propagatedBuildInputs = [
self."six"
self."funcsigs"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/a2/52/7edcd94f0afb721a2d559a5b9aae8af4f8f2c79bc63fdbe8a8a6c9b23bbe/mock-1.0.1.tar.gz";
sha256 = "0kzlsbki6q0awf89rc287f3aj8x431lrajf160a70z0ikhnxsfdq";
url = "https://files.pythonhosted.org/packages/2e/ab/4fe657d78b270aa6a32f027849513b829b41b0f28d9d8d7f8c3d29ea559a/mock-3.0.5.tar.gz";
sha256 = "1hrp6j0yrx2xzylfv02qa8kph661m6yq4p0mc8fnimch9j4psrc3";
};
meta = {
license = [ pkgs.lib.licenses.bsdOriginal ];
license = [ pkgs.lib.licenses.bsdOriginal { fullName = "OSI Approved :: BSD License"; } ];
};
};
"more-itertools" = super.buildPythonPackage {
@ -1253,11 +1257,11 @@ self: super: {
};
};
"py" = super.buildPythonPackage {
name = "py-1.6.0";
name = "py-1.8.0";
doCheck = false;
src = fetchurl {
url = "https://files.pythonhosted.org/packages/4f/38/5f427d1eedae73063ce4da680d2bae72014995f9fdeaa57809df61c968cd/py-1.6.0.tar.gz";
sha256 = "1wcs3zv9wl5m5x7p16avqj2gsrviyb23yvc3pr330isqs0sh98q6";
url = "https://files.pythonhosted.org/packages/f1/5a/87ca5909f400a2de1561f1648883af74345fe96349f34f737cdfc94eba8c/py-1.8.0.tar.gz";
sha256 = "0lsy1gajva083pzc7csj1cvbmminb7b4l6a0prdzyb3fd829nqyw";
};
meta = {
license = [ pkgs.lib.licenses.mit ];
@ -1492,44 +1496,46 @@ self: super: {
};
};
"pytest" = super.buildPythonPackage {
name = "pytest-3.8.2";
name = "pytest-4.6.5";
doCheck = false;
propagatedBuildInputs = [
self."py"
self."six"
self."setuptools"
self."packaging"
self."attrs"
self."more-itertools"
self."atomicwrites"
self."pluggy"
self."importlib-metadata"
self."wcwidth"
self."funcsigs"
self."pathlib2"
self."more-itertools"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/5f/d2/7f77f406ac505abda02ab4afb50d06ebf304f6ea42fca34f8f37529106b2/pytest-3.8.2.tar.gz";
sha256 = "18nrwzn61kph2y6gxwfz9ms68rfvr9d4vcffsxng9p7jk9z18clk";
url = "https://files.pythonhosted.org/packages/2a/c6/1d1f32f6a5009900521b12e6560fb6b7245b0d4bc3fb771acd63d10e30e1/pytest-4.6.5.tar.gz";
sha256 = "0iykwwfp4h181nd7rsihh2120b0rkawlw7rvbl19sgfspncr3hwg";
};
meta = {
license = [ pkgs.lib.licenses.mit ];
};
};
"pytest-cov" = super.buildPythonPackage {
name = "pytest-cov-2.6.0";
name = "pytest-cov-2.7.1";
doCheck = false;
propagatedBuildInputs = [
self."pytest"
self."coverage"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/d9/e2/58f90a316fbd94dd50bf5c826a23f3f5d079fb3cc448c1e9f0e3c33a3d2a/pytest-cov-2.6.0.tar.gz";
sha256 = "0qnpp9y3ygx4jk4pf5ad71fh2skbvnr6gl54m7rg5qysnx4g0q73";
url = "https://files.pythonhosted.org/packages/bb/0f/3db7ff86801883b21d5353b258c994b1b8e2abbc804e2273b8d0fd19004b/pytest-cov-2.7.1.tar.gz";
sha256 = "0filvmmyqm715azsl09ql8hy2x7h286n6d8z5x42a1wpvvys83p0";
};
meta = {
license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.mit ];
};
};
"pytest-profiling" = super.buildPythonPackage {
name = "pytest-profiling-1.3.0";
name = "pytest-profiling-1.7.0";
doCheck = false;
propagatedBuildInputs = [
self."six"
@ -1537,48 +1543,49 @@ self: super: {
self."gprof2dot"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/f5/34/4626126e041a51ef50a80d0619519b18d20aef249aac25b0d0fdd47e57ee/pytest-profiling-1.3.0.tar.gz";
sha256 = "08r5afx5z22yvpmsnl91l4amsy1yxn8qsmm61mhp06mz8zjs51kb";
url = "https://files.pythonhosted.org/packages/39/70/22a4b33739f07f1732a63e33bbfbf68e0fa58cfba9d200e76d01921eddbf/pytest-profiling-1.7.0.tar.gz";
sha256 = "0abz9gi26jpcfdzgsvwad91555lpgdc8kbymicmms8k2fqa8z4wk";
};
meta = {
license = [ pkgs.lib.licenses.mit ];
};
};
"pytest-runner" = super.buildPythonPackage {
name = "pytest-runner-4.2";
name = "pytest-runner-5.1";
doCheck = false;
src = fetchurl {
url = "https://files.pythonhosted.org/packages/9e/b7/fe6e8f87f9a756fd06722216f1b6698ccba4d269eac6329d9f0c441d0f93/pytest-runner-4.2.tar.gz";
sha256 = "1gkpyphawxz38ni1gdq1fmwyqcg02m7ypzqvv46z06crwdxi2gyj";
url = "https://files.pythonhosted.org/packages/d9/6d/4b41a74b31720e25abd4799be72d54811da4b4d0233e38b75864dcc1f7ad/pytest-runner-5.1.tar.gz";
sha256 = "0ykfcnpp8c22winj63qzc07l5axwlc9ikl8vn05sc32gv3417815";
};
meta = {
license = [ pkgs.lib.licenses.mit ];
};
};
"pytest-sugar" = super.buildPythonPackage {
name = "pytest-sugar-0.9.1";
name = "pytest-sugar-0.9.2";
doCheck = false;
propagatedBuildInputs = [
self."pytest"
self."termcolor"
self."packaging"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/3e/6a/a3f909083079d03bde11d06ab23088886bbe25f2c97fbe4bb865e2bf05bc/pytest-sugar-0.9.1.tar.gz";
sha256 = "0b4av40dv30727m54v211r0nzwjp2ajkjgxix6j484qjmwpw935b";
url = "https://files.pythonhosted.org/packages/55/59/f02f78d1c80f7e03e23177f60624c8106d4f23d124c921df103f65692464/pytest-sugar-0.9.2.tar.gz";
sha256 = "1asq7yc4g8bx2sn7yy974mhc9ywvaihasjab4inkirdwn9s7mn7w";
};
meta = {
license = [ pkgs.lib.licenses.bsdOriginal ];
};
};
"pytest-timeout" = super.buildPythonPackage {
name = "pytest-timeout-1.3.2";
name = "pytest-timeout-1.3.3";
doCheck = false;
propagatedBuildInputs = [
self."pytest"
];
src = fetchurl {
url = "https://files.pythonhosted.org/packages/8c/3e/1b6a319d12ae7baa3acb7c18ff2c8630a09471a0319d43535c683b4d03eb/pytest-timeout-1.3.2.tar.gz";
sha256 = "09wnmzvnls2mnsdz7x3c3sk2zdp6jl4dryvyj5i8hqz16q2zq5qi";
url = "https://files.pythonhosted.org/packages/13/48/7a166eaa29c1dca6cc253e3ba5773ff2e4aa4f567c1ea3905808e95ac5c1/pytest-timeout-1.3.3.tar.gz";
sha256 = "1cczcjhw4xx5sjkhxlhc5c1bkr7x6fcyx12wrnvwfckshdvblc2a";
};
meta = {
license = [ pkgs.lib.licenses.mit { fullName = "DFSG approved"; } ];

View file

@ -9,8 +9,11 @@ vcsserver_config_http = rhodecode/tests/vcsserver_http.ini
addopts =
--pdbcls=IPython.terminal.debugger:TerminalPdb
--strict-markers
markers =
vcs_operations: Mark tests depending on a running RhodeCode instance.
xfail_backends: Mark tests as xfail for given backends.
skip_backends: Mark tests as skipped for given backends.
backends: Mark backends
dbs: database markers for running tests for given DB

View file

@ -1,16 +1,16 @@
# test related requirements
pytest==3.8.2
py==1.6.0
pytest-cov==2.6.0
pytest-sugar==0.9.1
pytest-runner==4.2.0
pytest-profiling==1.3.0
pytest-timeout==1.3.2
pytest==4.6.5
py==1.8.0
pytest-cov==2.7.1
pytest-sugar==0.9.2
pytest-runner==5.1.0
pytest-profiling==1.7.0
pytest-timeout==1.3.3
gprof2dot==2017.9.19
mock==1.0.1
mock==3.0.5
cov-core==1.15.0
coverage==4.5.3
coverage==4.5.4
webtest==2.0.33
beautifulsoup4==4.6.3

View file

@ -31,36 +31,38 @@ from rhodecode.api.tests.utils import (
@pytest.fixture()
def make_repo_comments_factory(request):
def maker(repo):
user = User.get_first_super_admin()
commit = repo.scm_instance()[0]
class Make(object):
commit_id = commit.raw_id
file_0 = commit.affected_files[0]
comments = []
def make_comments(self, repo):
user = User.get_first_super_admin()
commit = repo.scm_instance()[0]
# general
CommentsModel().create(
text='General Comment', repo=repo, user=user, commit_id=commit_id,
comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
commit_id = commit.raw_id
file_0 = commit.affected_files[0]
comments = []
# inline
CommentsModel().create(
text='Inline Comment', repo=repo, user=user, commit_id=commit_id,
f_path=file_0, line_no='n1',
comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
# general
CommentsModel().create(
text='General Comment', repo=repo, user=user, commit_id=commit_id,
comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
# todo
CommentsModel().create(
text='INLINE TODO Comment', repo=repo, user=user, commit_id=commit_id,
f_path=file_0, line_no='n1',
comment_type=ChangesetComment.COMMENT_TYPE_TODO, send_email=False)
# inline
CommentsModel().create(
text='Inline Comment', repo=repo, user=user, commit_id=commit_id,
f_path=file_0, line_no='n1',
comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
@request.addfinalizer
def cleanup():
for comment in comments:
Session().delete(comment)
return maker
# todo
CommentsModel().create(
text='INLINE TODO Comment', repo=repo, user=user, commit_id=commit_id,
f_path=file_0, line_no='n1',
comment_type=ChangesetComment.COMMENT_TYPE_TODO, send_email=False)
@request.addfinalizer
def cleanup():
for comment in comments:
Session().delete(comment)
return Make()
@pytest.mark.usefixtures("testuser_api", "app")
@ -76,7 +78,7 @@ class TestGetRepo(object):
make_repo_comments_factory, filters, expected_count):
commits = [{'message': 'A'}, {'message': 'B'}]
repo = backend.create_repo(commits=commits)
make_repo_comments_factory(repo)
make_repo_comments_factory.make_comments(repo)
api_call_params = {'repoid': repo.repo_name,}
api_call_params.update(filters)
@ -92,12 +94,13 @@ class TestGetRepo(object):
assert len(result) == expected_count
def test_api_get_repo_comments_wrong_comment_typ(self, backend_hg):
def test_api_get_repo_comments_wrong_comment_type(
self, make_repo_comments_factory, backend_hg):
commits = [{'message': 'A'}, {'message': 'B'}]
repo = backend_hg.create_repo(commits=commits)
make_repo_comments_factory.make_comments(repo)
repo = backend_hg.create_repo()
make_repo_comments_factory(repo)
api_call_params = {'repoid': repo.repo_name,}
api_call_params = {'repoid': repo.repo_name}
api_call_params.update({'comment_type': 'bogus'})
expected = 'comment_type must be one of `{}` got {}'.format(

View file

@ -31,10 +31,11 @@ from rhodecode.tests.fixture import TestINI
def _get_dbs_from_metafunc(metafunc):
if hasattr(metafunc.function, 'dbs'):
# Supported backends by this test function, created from
# pytest.mark.dbs
backends = metafunc.definition.get_closest_marker('dbs').args
dbs_mark = metafunc.definition.get_closest_marker('dbs')
if dbs_mark:
# Supported backends by this test function, created from pytest.mark.dbs
backends = dbs_mark.args
else:
backends = metafunc.config.getoption('--dbs')
return backends

View file

@ -0,0 +1,47 @@
import collections
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2019 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
from rhodecode.lib import audit_logger
@pytest.mark.parametrize('store_type', [
'store_web',
'store_api'
])
@pytest.mark.parametrize('action, kwargs', [
('repo.edit', {
'user': audit_logger.UserWrap(username='test-audit-log', ip_addr='8.8.8.8'),
'action_data': {'data': {'hello': 'world'}}
}),
('repo.edit', {
'user': audit_logger.UserWrap(username=u'marcinkużmiń', ip_addr='8.8.8.8'),
'action_data': {'data': {'hello': u'ąężą∑ęķ©'}}
}),
('repo.edit', {
'user': audit_logger.UserWrap(username='marcinkużmiń', ip_addr='8.8.8.8'),
'action_data': {'data': {'hello': 'ąężą∑ęķ©'}}
}),
])
def test_store_audit_log(app, store_type, action, kwargs):
store_action = getattr(audit_logger, store_type)
store_action(action, **kwargs)

View file

@ -18,16 +18,11 @@
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import os
import stat
import sys
import pytest
from mock import Mock, patch, DEFAULT
import rhodecode
from rhodecode.model import db, scm
from rhodecode.tests import no_newline_id_generator
def test_scm_instance_config(backend):
@ -35,18 +30,17 @@ def test_scm_instance_config(backend):
with patch.multiple('rhodecode.model.db.Repository',
_get_instance=DEFAULT,
_get_instance_cached=DEFAULT) as mocks:
repo.scm_instance()
mocks['_get_instance'].assert_called_with(
config=None, cache=False)
config = {'some': 'value'}
repo.scm_instance(config=config)
repo.scm_instance(vcs_full_cache=False)
mocks['_get_instance'].assert_called_with(
config=config, cache=False)
config=None, cache=False)
with patch.dict(rhodecode.CONFIG, {'vcs_full_cache': 'true'}):
repo.scm_instance(config=config)
mocks['_get_instance_cached'].assert_called()
repo.scm_instance(vcs_full_cache=True)
mocks['_get_instance_cached'].assert_called()
def test_get_instance_config(backend):

View file

@ -30,7 +30,6 @@ import subprocess32
import time
import uuid
import dateutil.tz
import functools
import mock
import pyramid.testing
@ -67,6 +66,7 @@ from rhodecode.tests.utils import CustomTestApp, set_anonymous_access
from rhodecode.tests.fixture import Fixture
from rhodecode.config import utils as config_utils
def _split_comma(value):
return value.split(',')
@ -120,14 +120,18 @@ def pytest_collection_modifyitems(session, config, items):
def pytest_generate_tests(metafunc):
# Support test generation based on --backend parameter
if 'backend_alias' in metafunc.fixturenames:
backends = get_backends_from_metafunc(metafunc)
scope = None
if not backends:
pytest.skip("Not enabled for any of selected backends")
metafunc.parametrize('backend_alias', backends, scope=scope)
elif hasattr(metafunc.function, 'backends'):
backend_mark = metafunc.definition.get_closest_marker('backends')
if backend_mark:
backends = get_backends_from_metafunc(metafunc)
if not backends:
pytest.skip("Not enabled for any of selected backends")
@ -135,10 +139,11 @@ def pytest_generate_tests(metafunc):
def get_backends_from_metafunc(metafunc):
requested_backends = set(metafunc.config.getoption('--backends'))
if hasattr(metafunc.function, 'backends'):
backend_mark = metafunc.definition.get_closest_marker('backends')
if backend_mark:
# Supported backends by this test function, created from
# pytest.mark.backends
backends = metafunc.definition.get_closest_marker('backends').args
backends = backend_mark.args
elif hasattr(metafunc.cls, 'backend_alias'):
# Support class attribute "backend_alias", this is mainly
# for legacy reasons for tests not yet using pytest.mark.backends
@ -1810,17 +1815,3 @@ def repo_groups(request):
fixture.destroy_repo_group(parent_group)
return zombie_group, parent_group, child_group
@pytest.fixture(scope="session")
def tmp_path_factory(request):
"""Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
"""
class TempPathFactory:
def mktemp(self, basename):
import tempfile
return tempfile.mktemp(basename)
return TempPathFactory()

View file

@ -48,21 +48,21 @@ class TestGitRepository(object):
self.repo = GitRepository(TEST_GIT_REPO, bare=True)
self.repo.count()
def get_clone_repo(self, tmp_path_factory):
def get_clone_repo(self, tmpdir):
"""
Return a non bare clone of the base repo.
"""
clone_path = tmp_path_factory.mktemp('clone-url')
clone_path = str(tmpdir.join('clone-repo'))
repo_clone = GitRepository(
clone_path, create=True, src_url=self.repo.path, bare=False)
return repo_clone
def get_empty_repo(self, tmp_path_factory, bare=False):
def get_empty_repo(self, tmpdir, bare=False):
"""
Return a non bare empty repo.
"""
clone_path = tmp_path_factory.mktemp('empty-repo')
clone_path = str(tmpdir.join('empty-repo'))
return GitRepository(clone_path, create=True, bare=bare)
def test_wrong_repo_path(self):
@ -72,7 +72,7 @@ class TestGitRepository(object):
def test_repo_clone(self, tmp_path_factory):
repo = GitRepository(TEST_GIT_REPO)
clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE
clone_path = '{}_{}'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
repo_clone = GitRepository(
clone_path,
src_url=TEST_GIT_REPO, create=True, do_workspace_checkout=True)
@ -90,7 +90,7 @@ class TestGitRepository(object):
def test_repo_clone_with_update(self, tmp_path_factory):
repo = GitRepository(TEST_GIT_REPO)
clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_update'
clone_path = '{}_{}_update'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
repo_clone = GitRepository(
clone_path,
@ -103,7 +103,7 @@ class TestGitRepository(object):
def test_repo_clone_without_update(self, tmp_path_factory):
repo = GitRepository(TEST_GIT_REPO)
clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_without_update'
clone_path = '{}_{}_without_update'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
repo_clone = GitRepository(
clone_path,
create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=False)
@ -116,7 +116,7 @@ class TestGitRepository(object):
def test_repo_clone_into_bare_repo(self, tmp_path_factory):
repo = GitRepository(TEST_GIT_REPO)
clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_bare.git'
clone_path = '{}_{}_bare.git'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
repo_clone = GitRepository(
clone_path, create=True, src_url=repo.path, bare=True)
assert repo_clone.bare
@ -258,8 +258,8 @@ TODO: To be written...
def test_head(self):
assert self.repo.head == self.repo.get_commit().raw_id
def test_checkout_with_create(self, tmp_path_factory):
repo_clone = self.get_clone_repo(tmp_path_factory)
def test_checkout_with_create(self, tmpdir):
repo_clone = self.get_clone_repo(tmpdir)
new_branch = 'new_branch'
assert repo_clone._current_branch() == 'master'
@ -271,22 +271,22 @@ TODO: To be written...
assert set(repo_clone.branches) == {'master', new_branch}
assert repo_clone._current_branch() == new_branch
def test_checkout(self, tmp_path_factory):
repo_clone = self.get_clone_repo(tmp_path_factory)
def test_checkout(self, tmpdir):
repo_clone = self.get_clone_repo(tmpdir)
repo_clone._checkout('new_branch', create=True)
repo_clone._checkout('master')
assert repo_clone._current_branch() == 'master'
def test_checkout_same_branch(self, tmp_path_factory):
repo_clone = self.get_clone_repo(tmp_path_factory)
def test_checkout_same_branch(self, tmpdir):
repo_clone = self.get_clone_repo(tmpdir)
repo_clone._checkout('master')
assert repo_clone._current_branch() == 'master'
def test_checkout_branch_already_exists(self, tmp_path_factory):
repo_clone = self.get_clone_repo(tmp_path_factory)
def test_checkout_branch_already_exists(self, tmpdir):
repo_clone = self.get_clone_repo(tmpdir)
with pytest.raises(RepositoryError):
repo_clone._checkout('master', create=True)
@ -299,32 +299,32 @@ TODO: To be written...
with pytest.raises(RepositoryError):
self.repo._current_branch()
def test_current_branch_empty_repo(self, tmp_path_factory):
repo = self.get_empty_repo(tmp_path_factory)
def test_current_branch_empty_repo(self, tmpdir):
repo = self.get_empty_repo(tmpdir)
assert repo._current_branch() is None
def test_local_clone(self, tmp_path_factory):
clone_path = tmp_path_factory.mktemp('test-local-clone')
clone_path = str(tmp_path_factory.mktemp('test-local-clone'))
self.repo._local_clone(clone_path, 'master')
repo_clone = GitRepository(clone_path)
assert self.repo.commit_ids == repo_clone.commit_ids
def test_local_clone_with_specific_branch(self, tmp_path_factory):
source_repo = self.get_clone_repo(tmp_path_factory)
def test_local_clone_with_specific_branch(self, tmpdir):
source_repo = self.get_clone_repo(tmpdir)
# Create a new branch in source repo
new_branch_commit = source_repo.commit_ids[-3]
source_repo._checkout(new_branch_commit)
source_repo._checkout('new_branch', create=True)
clone_path = tmp_path_factory.mktemp('git-clone-path-1')
clone_path = str(tmpdir.join('git-clone-path-1'))
source_repo._local_clone(clone_path, 'new_branch')
repo_clone = GitRepository(clone_path)
assert source_repo.commit_ids[:-3 + 1] == repo_clone.commit_ids
clone_path = tmp_path_factory.mktemp('git-clone-path-2')
clone_path = str(tmpdir.join('git-clone-path-2'))
source_repo._local_clone(clone_path, 'master')
repo_clone = GitRepository(clone_path)
@ -334,9 +334,9 @@ TODO: To be written...
with pytest.raises(RepositoryError):
self.repo._local_clone(self.repo.path, 'master')
def test_local_fetch(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
source_repo = self.get_clone_repo(tmp_path_factory)
def test_local_fetch(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
source_repo = self.get_clone_repo(tmpdir)
# Create a new branch in source repo
master_commit = source_repo.commit_ids[-1]
@ -350,8 +350,8 @@ TODO: To be written...
target_repo._local_fetch(source_repo.path, 'master')
assert target_repo._last_fetch_heads() == [master_commit]
def test_local_fetch_from_bare_repo(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
def test_local_fetch_from_bare_repo(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
target_repo._local_fetch(self.repo.path, 'master')
master_commit = self.repo.commit_ids[-1]
@ -361,15 +361,15 @@ TODO: To be written...
with pytest.raises(ValueError):
self.repo._local_fetch(self.repo.path, 'master')
def test_local_fetch_branch_does_not_exist(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
def test_local_fetch_branch_does_not_exist(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
with pytest.raises(RepositoryError):
target_repo._local_fetch(self.repo.path, 'new_branch')
def test_local_pull(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
source_repo = self.get_clone_repo(tmp_path_factory)
def test_local_pull(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
source_repo = self.get_clone_repo(tmpdir)
# Create a new branch in source repo
master_commit = source_repo.commit_ids[-1]
@ -389,9 +389,9 @@ TODO: To be written...
with pytest.raises(RepositoryError):
self.repo._local_pull(self.repo.path, 'master')
def test_local_merge(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
source_repo = self.get_clone_repo(tmp_path_factory)
def test_local_merge(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
source_repo = self.get_clone_repo(tmpdir)
# Create a new branch in source repo
master_commit = source_repo.commit_ids[-1]
@ -432,8 +432,8 @@ TODO: To be written...
assert not os.path.exists(
os.path.join(target_repo.path, '.git', 'MERGE_HEAD'))
def test_local_merge_into_empty_repo(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
def test_local_merge_into_empty_repo(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
# This is required as one cannot do a -ff-only merge in an empty repo.
target_repo._local_fetch(self.repo.path, 'master')
@ -447,8 +447,8 @@ TODO: To be written...
self.repo._local_merge(
'merge_message', 'user name', 'user@name.com', None)
def test_local_push_non_bare(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
def test_local_push_non_bare(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
pushed_branch = 'pushed_branch'
self.repo._local_push('master', target_repo.path, pushed_branch)
@ -462,8 +462,8 @@ TODO: To be written...
assert (target_repo.branches[pushed_branch] ==
self.repo.branches['master'])
def test_local_push_bare(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
def test_local_push_bare(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir, bare=True)
pushed_branch = 'pushed_branch'
self.repo._local_push('master', target_repo.path, pushed_branch)
@ -477,8 +477,8 @@ TODO: To be written...
assert (target_repo.branches[pushed_branch] ==
self.repo.branches['master'])
def test_local_push_non_bare_target_branch_is_checked_out(self, tmp_path_factory):
target_repo = self.get_clone_repo(tmp_path_factory)
def test_local_push_non_bare_target_branch_is_checked_out(self, tmpdir):
target_repo = self.get_clone_repo(tmpdir)
pushed_branch = 'pushed_branch'
# Create a new branch in source repo
@ -498,8 +498,8 @@ TODO: To be written...
with pytest.raises(RepositoryError):
self.repo._local_push('master', target_repo.path, 'master')
def test_hooks_can_be_enabled_via_env_variable_for_local_push(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
def test_hooks_can_be_enabled_via_env_variable_for_local_push(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir, bare=True)
with mock.patch.object(self.repo, 'run_git_command') as run_mock:
self.repo._local_push(
@ -523,8 +523,8 @@ TODO: To be written...
f.write('\n'.join(script_lines))
os.chmod(hook_path, 0o755)
def test_local_push_does_not_execute_hook(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory)
def test_local_push_does_not_execute_hook(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir)
pushed_branch = 'pushed_branch'
self._add_failing_hook(target_repo.path, 'pre-receive')
@ -539,8 +539,8 @@ TODO: To be written...
assert (target_repo.branches[pushed_branch] ==
self.repo.branches['master'])
def test_local_push_executes_hook(self, tmp_path_factory):
target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
def test_local_push_executes_hook(self, tmpdir):
target_repo = self.get_empty_repo(tmpdir, bare=True)
self._add_failing_hook(target_repo.path, 'pre-receive', bare=True)
with pytest.raises(RepositoryError):
self.repo._local_push(