本文整理汇总了Python中testing.fixtures.make_repo函数的典型用法代码示例。如果您正苦于以下问题:Python make_repo函数的具体用法?Python make_repo怎么用?Python make_repo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_repo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_control_c_control_c_on_install
def test_control_c_control_c_on_install(tmpdir_factory, store):
"""Regression test for #186."""
path = make_repo(tmpdir_factory, 'python_hooks_repo')
config = make_config_from_repo(path)
repo = Repository.create(config, store)
hook = repo.hooks[0][1]
class MyKeyboardInterrupt(KeyboardInterrupt):
pass
# To simulate a killed install, we'll make PythonEnv.run raise ^C
# and then to simulate a second ^C during cleanup, we'll make shutil.rmtree
# raise as well.
with pytest.raises(MyKeyboardInterrupt):
with mock.patch.object(
PythonEnv, 'run', side_effect=MyKeyboardInterrupt,
):
with mock.patch.object(
shutil, 'rmtree', side_effect=MyKeyboardInterrupt,
):
repo.run_hook(hook, [])
# Should have made an environment, however this environment is broken!
assert os.path.exists(repo.cmd_runner.path('py_env'))
# However, it should be perfectly runnable (reinstall after botched
# install)
retv, stdout, stderr = repo.run_hook(hook, [])
assert retv == 0
示例2: test_autoupdate_old_revision_broken
def test_autoupdate_old_revision_broken(
tempdir_factory, in_tmpdir, mock_out_store_directory,
):
"""In $FUTURE_VERSION, hooks.yaml will no longer be supported. This
asserts that when that day comes, pre-commit will be able to autoupdate
despite not being able to read hooks.yaml in that repository.
"""
path = make_repo(tempdir_factory, 'python_hooks_repo')
config = make_config_from_repo(path, check=False)
with cwd(path):
cmd_output('git', 'mv', C.MANIFEST_FILE, 'nope.yaml')
cmd_output('git', 'commit', '-m', 'simulate old repo')
# Assume this is the revision the user's old repository was at
rev = get_head_sha(path)
cmd_output('git', 'mv', 'nope.yaml', C.MANIFEST_FILE)
cmd_output('git', 'commit', '-m', 'move hooks file')
update_rev = get_head_sha(path)
config['sha'] = rev
write_config('.', config)
before = open(C.CONFIG_FILE).read()
ret = autoupdate(Runner('.', C.CONFIG_FILE), tags_only=False)
after = open(C.CONFIG_FILE).read()
assert ret == 0
assert before != after
assert update_rev in after
示例3: test_autoupdate_old_revision_broken
def test_autoupdate_old_revision_broken(tempdir_factory, in_tmpdir, store):
"""In $FUTURE_VERSION, hooks.yaml will no longer be supported. This
asserts that when that day comes, pre-commit will be able to autoupdate
despite not being able to read hooks.yaml in that repository.
"""
path = make_repo(tempdir_factory, 'python_hooks_repo')
config = make_config_from_repo(path, check=False)
cmd_output('git', 'mv', C.MANIFEST_FILE, 'nope.yaml', cwd=path)
git_commit(cwd=path)
# Assume this is the revision the user's old repository was at
rev = git.head_rev(path)
cmd_output('git', 'mv', 'nope.yaml', C.MANIFEST_FILE, cwd=path)
git_commit(cwd=path)
update_rev = git.head_rev(path)
config['rev'] = rev
write_config('.', config)
with open(C.CONFIG_FILE) as f:
before = f.read()
ret = autoupdate(C.CONFIG_FILE, store, tags_only=False)
with open(C.CONFIG_FILE) as f:
after = f.read()
assert ret == 0
assert before != after
assert update_rev in after
示例4: test_default_python_language_version
def test_default_python_language_version(store, tempdir_factory):
path = make_repo(tempdir_factory, 'python_hooks_repo')
repo_path = store.clone(path, get_head_sha(path))
manifest = Manifest(repo_path, path)
# This assertion is difficult as it is version dependent, just assert
# that it is *something*
assert manifest.hooks['foo']['language_version'] != 'default'
示例5: hook_disappearing_repo
def hook_disappearing_repo(tempdir_factory):
path = make_repo(tempdir_factory, 'python_hooks_repo')
original_rev = git.head_rev(path)
with modify_manifest(path) as manifest:
manifest[0]['id'] = 'bar'
yield auto_namedtuple(path=path, original_rev=original_rev)
示例6: test_additional_python_dependencies_installed
def test_additional_python_dependencies_installed(tempdir_factory, store):
path = make_repo(tempdir_factory, 'python_hooks_repo')
config = make_config_from_repo(path)
config['hooks'][0]['additional_dependencies'] = ['mccabe']
repo = Repository.create(config, store)
repo.run_hook(repo.hooks[0][1], [])
with python.in_env(repo.cmd_runner, 'default') as env:
output = env.run('pip freeze -l')[1]
assert 'mccabe' in output
示例7: test_config_overrides_repo_specifics
def test_config_overrides_repo_specifics(tempdir_factory, store):
path = make_repo(tempdir_factory, "script_hooks_repo")
config = make_config_from_repo(path)
repo = Repository.create(config, store)
assert repo.hooks[0][1]["files"] == ""
# Set the file regex to something else
config["hooks"][0]["files"] = "\\.sh$"
repo = Repository.create(config, store)
assert repo.hooks[0][1]["files"] == "\\.sh$"
示例8: _test_hook_repo
def _test_hook_repo(
tempdir_factory, store, repo_path, hook_id, args, expected, expected_return_code=0, config_kwargs=None
):
path = make_repo(tempdir_factory, repo_path)
config = make_config_from_repo(path, **(config_kwargs or {}))
repo = Repository.create(config, store)
hook_dict = [hook for repo_hook_id, hook in repo.hooks if repo_hook_id == hook_id][0]
ret = repo.run_hook(hook_dict, args)
assert ret[0] == expected_return_code
assert ret[1].replace(b"\r\n", b"\n") == expected
示例9: test_config_overrides_repo_specifics
def test_config_overrides_repo_specifics(tmpdir_factory, store):
path = make_repo(tmpdir_factory, 'script_hooks_repo')
config = make_config_from_repo(path)
repo = Repository.create(config, store)
assert repo.hooks[0][1]['files'] == ''
# Set the file regex to something else
config['hooks'][0]['files'] = '\\.sh$'
repo = Repository.create(config, store)
assert repo.hooks[0][1]['files'] == '\\.sh$'
示例10: out_of_date_repo
def out_of_date_repo(tempdir_factory):
path = make_repo(tempdir_factory, 'python_hooks_repo')
original_rev = git.head_rev(path)
git_commit(cwd=path)
head_rev = git.head_rev(path)
yield auto_namedtuple(
path=path, original_rev=original_rev, head_rev=head_rev,
)
示例11: test_additional_ruby_dependencies_installed
def test_additional_ruby_dependencies_installed(
tempdir_factory, store,
): # pragma: no cover (non-windows)
path = make_repo(tempdir_factory, 'ruby_hooks_repo')
config = make_config_from_repo(path)
config['hooks'][0]['additional_dependencies'] = ['thread_safe']
repo = Repository.create(config, store)
repo.run_hook(repo.hooks[0][1], [])
with ruby.in_env(repo.cmd_runner, 'default') as env:
output = env.run('gem list --local')[1]
assert 'thread_safe' in output
示例12: test_really_long_file_paths
def test_really_long_file_paths(tempdir_factory, store):
base_path = tempdir_factory.get()
really_long_path = os.path.join(base_path, "really_long" * 10)
cmd_output("git", "init", really_long_path)
path = make_repo(tempdir_factory, "python_hooks_repo")
config = make_config_from_repo(path)
with cwd(really_long_path):
repo = Repository.create(config, store)
repo.require_installed()
示例13: test_gc_repo_not_cloned
def test_gc_repo_not_cloned(tempdir_factory, store, in_git_dir, cap_out):
path = make_repo(tempdir_factory, 'script_hooks_repo')
write_config('.', make_config_from_repo(path))
store.mark_config_used(C.CONFIG_FILE)
assert _config_count(store) == 1
assert _repo_count(store) == 0
assert not gc(store)
assert _config_count(store) == 1
assert _repo_count(store) == 0
assert cap_out.get().splitlines()[-1] == '0 repo(s) removed.'
示例14: test_really_long_file_paths
def test_really_long_file_paths(tmpdir_factory, store):
base_path = tmpdir_factory.get()
really_long_path = os.path.join(base_path, 'really_long' * 10)
cmd_output('git', 'init', really_long_path)
path = make_repo(tmpdir_factory, 'python_hooks_repo')
config = make_config_from_repo(path)
with cwd(really_long_path):
repo = Repository.create(config, store)
repo.require_installed()
示例15: out_of_date_repo
def out_of_date_repo(tmpdir_factory):
path = make_repo(tmpdir_factory, 'python_hooks_repo')
original_sha = get_head_sha(path)
# Make a commit
with local.cwd(path):
local['git']['commit', '--allow-empty', '-m', 'foo']()
head_sha = get_head_sha(path)
yield auto_namedtuple(
path=path, original_sha=original_sha, head_sha=head_sha,
)