• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fixtures.add_config_to_repo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_useless_exclude_with_types_filter

def test_useless_exclude_with_types_filter(capsys, in_git_dir):
    config = {
        'repos': [
            {
                'repo': 'meta',
                'hooks': [
                    {
                        'id': 'check-useless-excludes',
                        'exclude': '.pre-commit-config.yaml',
                        'types': ['python'],
                    },
                ],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_useless_excludes.main(()) == 1

    out, _ = capsys.readouterr()
    out = out.strip()
    expected = (
        "The exclude pattern '.pre-commit-config.yaml' for "
        'check-useless-excludes does not match any files'
    )
    assert expected == out
开发者ID:pre-commit,项目名称:pre-commit,代码行数:27,代码来源:check_useless_excludes_test.py


示例2: test_local_hooks

def test_local_hooks(tempdir_factory, mock_out_store_directory):
    config = OrderedDict((
        ('repo', 'local'),
        (
            'hooks', (
                OrderedDict((
                    ('id', 'arg-per-line'),
                    ('name', 'Args per line hook'),
                    ('entry', 'bin/hook.sh'),
                    ('language', 'script'),
                    ('files', ''),
                    ('args', ['hello', 'world']),
                )), OrderedDict((
                    ('id', 'do_not_commit'),
                    ('name', 'Block if "DO NOT COMMIT" is found'),
                    ('entry', 'DO NOT COMMIT'),
                    ('language', 'pcre'),
                    ('files', '^(.*)$'),
                )),
            ),
        ),
    ))
    git_path = git_dir(tempdir_factory)
    add_config_to_repo(git_path, config)
    runner = Runner(git_path, C.CONFIG_FILE)
    assert len(runner.repositories) == 1
    assert len(runner.repositories[0].hooks) == 2
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:27,代码来源:runner_test.py


示例3: test_args_hook_only

def test_args_hook_only(cap_out, store, repo_with_passing_hook):
    config = {
        'repo': 'local',
        'hooks': [
            {
                'id': 'flake8',
                'name': 'flake8',
                'entry': "'{}' -m flake8".format(sys.executable),
                'language': 'system',
                'stages': ['commit'],
            },
            {
                'id': 'do_not_commit',
                'name': 'Block if "DO NOT COMMIT" is found',
                'entry': 'DO NOT COMMIT',
                'language': 'pygrep',
            },
        ],
    }
    add_config_to_repo(repo_with_passing_hook, config)
    stage_a_file()
    ret, printed = _do_run(
        cap_out,
        store,
        repo_with_passing_hook,
        run_opts(hook='do_not_commit'),
    )
    assert b'flake8' not in printed
开发者ID:pre-commit,项目名称:pre-commit,代码行数:28,代码来源:run_test.py


示例4: test_local_hook_fails

def test_local_hook_fails(cap_out, store, repo_with_passing_hook):
    config = {
        'repo': 'local',
        'hooks': [{
            'id': 'no-todo',
            'name': 'No TODO',
            'entry': 'sh -c "! grep -iI todo [email protected]" --',
            'language': 'system',
        }],
    }
    add_config_to_repo(repo_with_passing_hook, config)

    with io.open('dummy.py', 'w') as staged_file:
        staged_file.write('"""TODO: something"""\n')
    cmd_output('git', 'add', 'dummy.py')

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        opts={},
        expected_outputs=[b''],
        expected_ret=1,
        stage=False,
    )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:25,代码来源:run_test.py


示例5: test_local_hook_passes

def test_local_hook_passes(cap_out, store, repo_with_passing_hook):
    config = {
        'repo': 'local',
        'hooks': [
            {
                'id': 'flake8',
                'name': 'flake8',
                'entry': "'{}' -m flake8".format(sys.executable),
                'language': 'system',
                'files': r'\.py$',
            },
            {
                'id': 'do_not_commit',
                'name': 'Block if "DO NOT COMMIT" is found',
                'entry': 'DO NOT COMMIT',
                'language': 'pygrep',
            },
        ],
    }
    add_config_to_repo(repo_with_passing_hook, config)

    with io.open('dummy.py', 'w') as staged_file:
        staged_file.write('"""TODO: something"""\n')
    cmd_output('git', 'add', 'dummy.py')

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        opts={},
        expected_outputs=[b''],
        expected_ret=0,
        stage=False,
    )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:34,代码来源:run_test.py


示例6: test_autoupdate_local_hooks

def test_autoupdate_local_hooks(in_git_dir, store):
    config = sample_local_config()
    add_config_to_repo('.', config)
    assert autoupdate(C.CONFIG_FILE, store, tags_only=False) == 0
    new_config_writen = read_config('.')
    assert len(new_config_writen['repos']) == 1
    assert new_config_writen['repos'][0] == config
开发者ID:pre-commit,项目名称:pre-commit,代码行数:7,代码来源:autoupdate_test.py


示例7: test_local_hook_passes

def test_local_hook_passes(repo_with_passing_hook, mock_out_store_directory):
    config = OrderedDict((
        ('repo', 'local'),
        ('hooks', (OrderedDict((
            ('id', 'pylint'),
            ('name', 'PyLint'),
            ('entry', 'python -m pylint.__main__'),
            ('language', 'system'),
            ('files', r'\.py$'),
        )), OrderedDict((
            ('id', 'do_not_commit'),
            ('name', 'Block if "DO NOT COMMIT" is found'),
            ('entry', 'DO NOT COMMIT'),
            ('language', 'pcre'),
            ('files', '^(.*)$'),
        ))))
    ))
    add_config_to_repo(repo_with_passing_hook, config)

    with io.open('dummy.py', 'w') as staged_file:
        staged_file.write('"""TODO: something"""\n')
    cmd_output('git', 'add', 'dummy.py')

    _test_run(
        repo_with_passing_hook,
        options={},
        expected_outputs=[b''],
        expected_ret=0,
        stage=False
    )
开发者ID:akramhussein,项目名称:pre-commit,代码行数:30,代码来源:run_test.py


示例8: test_meta_hook_passes

def test_meta_hook_passes(cap_out, store, repo_with_passing_hook):
    add_config_to_repo(repo_with_passing_hook, sample_meta_config())

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        opts={},
        expected_outputs=[b'Check for useless excludes'],
        expected_ret=0,
        stage=False,
    )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:12,代码来源:run_test.py


示例9: test_no_excludes

def test_no_excludes(capsys, in_git_dir):
    config = {
        'repos': [
            {
                'repo': 'meta',
                'hooks': [{'id': 'check-useless-excludes'}],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_useless_excludes.main(()) == 0

    out, _ = capsys.readouterr()
    assert out == ''
开发者ID:pre-commit,项目名称:pre-commit,代码行数:16,代码来源:check_useless_excludes_test.py


示例10: test_always_run_alt_config

def test_always_run_alt_config(cap_out, store, repo_with_passing_hook):
    repo_root = '.'
    config = read_config(repo_root)
    config['repos'][0]['hooks'][0]['always_run'] = True
    alt_config_file = 'alternate_config.yaml'
    add_config_to_repo(repo_root, config, config_file=alt_config_file)

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        {},
        (b'Bash hook', b'Passed'),
        0,
        stage=False,
        config_file=alt_config_file,
    )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:17,代码来源:run_test.py


示例11: test_push_hook

def test_push_hook(cap_out, repo_with_passing_hook, mock_out_store_directory):
    config = OrderedDict((
        ('repo', 'local'),
        (
            'hooks', (
                OrderedDict((
                    ('id', 'flake8'),
                    ('name', 'hook 1'),
                    ('entry', "'{}' -m flake8".format(sys.executable)),
                    ('language', 'system'),
                    ('types', ['python']),
                    ('stages', ['commit']),
                )),
                OrderedDict((
                    ('id', 'do_not_commit'),
                    ('name', 'hook 2'),
                    ('entry', 'DO NOT COMMIT'),
                    ('language', 'pcre'),
                    ('types', ['text']),
                    ('stages', ['push']),
                )),
            ),
        ),
    ))
    add_config_to_repo(repo_with_passing_hook, config)

    open('dummy.py', 'a').close()
    cmd_output('git', 'add', 'dummy.py')

    _test_run(
        cap_out,
        repo_with_passing_hook,
        {'hook_stage': 'commit'},
        expected_outputs=[b'hook 1'],
        expected_ret=0,
        stage=False,
    )

    _test_run(
        cap_out,
        repo_with_passing_hook,
        {'hook_stage': 'push'},
        expected_outputs=[b'hook 2'],
        expected_ret=0,
        stage=False,
    )
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:46,代码来源:run_test.py


示例12: test_autoupdate_local_hooks

def test_autoupdate_local_hooks(tempdir_factory):
    git_path = git_dir(tempdir_factory)
    config = config_with_local_hooks()
    path = add_config_to_repo(git_path, config)
    runner = Runner(path, C.CONFIG_FILE)
    assert autoupdate(runner, tags_only=False) == 0
    new_config_writen = load_config(runner.config_file_path)
    assert len(new_config_writen['repos']) == 1
    assert new_config_writen['repos'][0] == config
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:9,代码来源:autoupdate_test.py


示例13: test_autoupdate_local_hooks

def test_autoupdate_local_hooks(tmpdir_factory):
    git_path = git_dir(tmpdir_factory)
    config = config_with_local_hooks()
    path = add_config_to_repo(git_path, config)
    runner = Runner(path)
    assert autoupdate(runner) == 0
    new_config_writen = load_config(runner.config_file_path)
    assert len(new_config_writen) == 1
    assert new_config_writen[0] == config
开发者ID:rolka,项目名称:pre-commit,代码行数:9,代码来源:autoupdate_test.py


示例14: test_useless_exclude_global

def test_useless_exclude_global(capsys, in_git_dir):
    config = {
        'exclude': 'foo',
        'repos': [
            {
                'repo': 'meta',
                'hooks': [{'id': 'check-useless-excludes'}],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_useless_excludes.main(()) == 1

    out, _ = capsys.readouterr()
    out = out.strip()
    assert "The global exclude pattern 'foo' does not match any files" == out
开发者ID:pre-commit,项目名称:pre-commit,代码行数:18,代码来源:check_useless_excludes_test.py


示例15: test_valid_exceptions

def test_valid_exceptions(capsys, in_git_dir, mock_store_dir):
    config = {
        'repos': [
            {
                'repo': 'local',
                'hooks': [
                    # applies to a file
                    {
                        'id': 'check-yaml',
                        'name': 'check yaml',
                        'entry': './check-yaml',
                        'language': 'script',
                        'files': r'\.yaml$',
                    },
                    # Should not be reported as an error due to language: fail
                    {
                        'id': 'changelogs-rst',
                        'name': 'changelogs must be rst',
                        'entry': 'changelog filenames must end in .rst',
                        'language': 'fail',
                        'files': r'changelog/.*(?<!\.rst)$',
                    },
                    # Should not be reported as an error due to always_run
                    {
                        'id': 'i-always-run',
                        'name': 'make check',
                        'entry': 'make check',
                        'language': 'system',
                        'files': '^$',
                        'always_run': True,
                    },
                ],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_hooks_apply.main(()) == 0

    out, _ = capsys.readouterr()
    assert out == ''
开发者ID:pre-commit,项目名称:pre-commit,代码行数:42,代码来源:check_hooks_apply_test.py


示例16: test_useless_exclude_for_hook

def test_useless_exclude_for_hook(capsys, in_git_dir):
    config = {
        'repos': [
            {
                'repo': 'meta',
                'hooks': [{'id': 'check-useless-excludes', 'exclude': 'foo'}],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_useless_excludes.main(()) == 1

    out, _ = capsys.readouterr()
    out = out.strip()
    expected = (
        "The exclude pattern 'foo' for check-useless-excludes "
        'does not match any files'
    )
    assert expected == out
开发者ID:pre-commit,项目名称:pre-commit,代码行数:21,代码来源:check_useless_excludes_test.py


示例17: test_hook_types_excludes_everything

def test_hook_types_excludes_everything(capsys, in_git_dir, mock_store_dir):
    config = {
        'repos': [
            {
                'repo': 'meta',
                'hooks': [
                    {
                        'id': 'check-useless-excludes',
                        'exclude_types': ['yaml'],
                    },
                ],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_hooks_apply.main(()) == 1

    out, _ = capsys.readouterr()
    assert 'check-useless-excludes does not apply to this repository' in out
开发者ID:pre-commit,项目名称:pre-commit,代码行数:21,代码来源:check_hooks_apply_test.py


示例18: test_valid_exclude

def test_valid_exclude(capsys, in_git_dir):
    config = {
        'repos': [
            {
                'repo': 'meta',
                'hooks': [
                    {
                        'id': 'check-useless-excludes',
                        'exclude': '.pre-commit-config.yaml',
                    },
                ],
            },
        ],
    }

    add_config_to_repo(in_git_dir.strpath, config)

    assert check_useless_excludes.main(()) == 0

    out, _ = capsys.readouterr()
    assert out == ''
开发者ID:pre-commit,项目名称:pre-commit,代码行数:21,代码来源:check_useless_excludes_test.py


示例19: test_local_hook_passes

def test_local_hook_passes(
        cap_out, repo_with_passing_hook, mock_out_store_directory,
):
    config = OrderedDict((
        ('repo', 'local'),
        (
            'hooks', (
                OrderedDict((
                    ('id', 'flake8'),
                    ('name', 'flake8'),
                    ('entry', "'{}' -m flake8".format(sys.executable)),
                    ('language', 'system'),
                    ('files', r'\.py$'),
                )), OrderedDict((
                    ('id', 'do_not_commit'),
                    ('name', 'Block if "DO NOT COMMIT" is found'),
                    ('entry', 'DO NOT COMMIT'),
                    ('language', 'pcre'),
                    ('files', '^(.*)$'),
                )),
            ),
        ),
    ))
    add_config_to_repo(repo_with_passing_hook, config)

    with io.open('dummy.py', 'w') as staged_file:
        staged_file.write('"""TODO: something"""\n')
    cmd_output('git', 'add', 'dummy.py')

    _test_run(
        cap_out,
        repo_with_passing_hook,
        opts={},
        expected_outputs=[b''],
        expected_ret=0,
        stage=False,
    )
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:37,代码来源:run_test.py


示例20: test_pcre_deprecation_warning

def test_pcre_deprecation_warning(cap_out, store, repo_with_passing_hook):
    config = {
        'repo': 'local',
        'hooks': [{
            'id': 'pcre-hook',
            'name': 'pcre-hook',
            'language': 'pcre',
            'entry': '.',
        }],
    }
    add_config_to_repo(repo_with_passing_hook, config)

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        opts={},
        expected_outputs=[
            b'[WARNING] `pcre-hook` (from local) uses the deprecated '
            b'pcre language.',
        ],
        expected_ret=0,
        stage=False,
    )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:24,代码来源:run_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fixtures.git_dir函数代码示例发布时间:2022-05-27
下一篇:
Python builders.make_album函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap