当前位置: 首页>>代码示例>>Python>>正文


Python fixtures.make_config_from_repo函数代码示例

本文整理汇总了Python中testing.fixtures.make_config_from_repo函数的典型用法代码示例。如果您正苦于以下问题:Python make_config_from_repo函数的具体用法?Python make_config_from_repo怎么用?Python make_config_from_repo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_config_from_repo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tags_on_repositories

def test_tags_on_repositories(in_tmpdir, tempdir_factory, store):
    tag = "v1.1"
    git_dir_1 = _create_repo_with_tags(tempdir_factory, "prints_cwd_repo", tag)
    git_dir_2 = _create_repo_with_tags(tempdir_factory, "script_hooks_repo", tag)

    repo_1 = Repository.create(make_config_from_repo(git_dir_1, sha=tag), store)
    ret = repo_1.run_hook(repo_1.hooks[0][1], ["-L"])
    assert ret[0] == 0
    assert ret[1].strip() == _norm_pwd(in_tmpdir)

    repo_2 = Repository.create(make_config_from_repo(git_dir_2, sha=tag), store)
    ret = repo_2.run_hook(repo_2.hooks[0][1], ["bar"])
    assert ret[0] == 0
    assert ret[1] == b"bar\nHello World\n"
开发者ID:hitul007,项目名称:pre-commit,代码行数:14,代码来源:repository_test.py

示例2: 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
开发者ID:pre-commit,项目名称:pre-commit,代码行数:26,代码来源:autoupdate_test.py

示例3: test_out_of_date_repo

def test_out_of_date_repo(out_of_date_repo, store):
    config = make_config_from_repo(
        out_of_date_repo.path, rev=out_of_date_repo.original_rev,
    )
    ret = _update_repo(config, store, tags_only=False)
    assert ret['rev'] != out_of_date_repo.original_rev
    assert ret['rev'] == out_of_date_repo.head_rev
开发者ID:pre-commit,项目名称:pre-commit,代码行数:7,代码来源:autoupdate_test.py

示例4: run_on_version

 def run_on_version(version, expected_output):
     config = make_config_from_repo(path, hooks=[{"id": "python3-hook", "language_version": version}])
     repo = Repository.create(config, store)
     hook_dict, = [hook for repo_hook_id, hook in repo.hooks if repo_hook_id == "python3-hook"]
     ret = repo.run_hook(hook_dict, [])
     assert ret[0] == 0
     assert ret[1].replace(b"\r\n", b"\n") == expected_output
开发者ID:hitul007,项目名称:pre-commit,代码行数:7,代码来源:repository_test.py

示例5: 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
开发者ID:caffodian,项目名称:pre-commit,代码行数:29,代码来源:repository_test.py

示例6: test_out_of_date_repo

def test_out_of_date_repo(out_of_date_repo, runner_with_mocked_store):
    config = make_config_from_repo(
        out_of_date_repo.path, sha=out_of_date_repo.original_sha,
    )
    ret = _update_repository(config, runner_with_mocked_store)
    assert ret['sha'] != out_of_date_repo.original_sha
    assert ret['sha'] == out_of_date_repo.head_sha
开发者ID:bukzor,项目名称:pre-commit,代码行数:7,代码来源:autoupdate_test.py

示例7: 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
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:27,代码来源:autoupdate_test.py

示例8: test_hook_disppearing_repo_raises

def test_hook_disppearing_repo_raises(hook_disappearing_repo, store):
    config = make_config_from_repo(
        hook_disappearing_repo.path,
        rev=hook_disappearing_repo.original_rev,
        hooks=[{'id': 'foo'}],
    )
    with pytest.raises(RepositoryCannotBeUpdatedError):
        _update_repo(config, store, tags_only=False)
开发者ID:pre-commit,项目名称:pre-commit,代码行数:8,代码来源:autoupdate_test.py

示例9: 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
开发者ID:jdb8,项目名称:pre-commit,代码行数:9,代码来源:repository_test.py

示例10: 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$'
开发者ID:caffodian,项目名称:pre-commit,代码行数:10,代码来源:repository_test.py

示例11: test_autoupdate_tagged_repo

def test_autoupdate_tagged_repo(tagged_repo, in_tmpdir, store):
    config = make_config_from_repo(
        tagged_repo.path, rev=tagged_repo.original_rev,
    )
    write_config('.', config)

    ret = autoupdate(C.CONFIG_FILE, store, tags_only=False)
    assert ret == 0
    with open(C.CONFIG_FILE) as f:
        assert 'v1.2.3' in f.read()
开发者ID:pre-commit,项目名称:pre-commit,代码行数:10,代码来源:autoupdate_test.py

示例12: 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$"
开发者ID:hitul007,项目名称:pre-commit,代码行数:10,代码来源:repository_test.py

示例13: _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
开发者ID:hitul007,项目名称:pre-commit,代码行数:10,代码来源:repository_test.py

示例14: test_hook_disppearing_repo_raises

def test_hook_disppearing_repo_raises(
        hook_disappearing_repo, runner_with_mocked_store
):
    config = make_config_from_repo(
        hook_disappearing_repo.path,
        sha=hook_disappearing_repo.original_sha,
        hooks=[OrderedDict((('id', 'foo'),))],
    )
    with pytest.raises(RepositoryCannotBeUpdatedError):
        _update_repository(config, runner_with_mocked_store)
开发者ID:bukzor,项目名称:pre-commit,代码行数:10,代码来源:autoupdate_test.py

示例15: 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
开发者ID:jdb8,项目名称:pre-commit,代码行数:11,代码来源:repository_test.py


注:本文中的testing.fixtures.make_config_from_repo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。