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

Python fixtures.make_consuming_repo函数代码示例

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

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



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

示例1: test_pre_push_legacy

def test_pre_push_legacy(tempdir_factory, store):
    upstream = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    path = tempdir_factory.get()
    cmd_output('git', 'clone', upstream, path)
    with cwd(path):
        mkdirp(os.path.join(path, '.git/hooks'))
        with io.open(os.path.join(path, '.git/hooks/pre-push'), 'w') as f:
            f.write(
                '#!/usr/bin/env bash\n'
                'set -eu\n'
                'read lr ls rr rs\n'
                'test -n "$lr" -a -n "$ls" -a -n "$rr" -a -n "$rs"\n'
                'echo legacy\n',
            )
        make_executable(f.name)

        install(C.CONFIG_FILE, store, hook_type='pre-push')
        assert _get_commit_output(tempdir_factory)[0] == 0

        retc, output = _get_push_output(tempdir_factory)
        assert retc == 0
        first_line, _, third_line = output.splitlines()[:3]
        assert first_line == 'legacy'
        assert third_line.startswith('Bash hook')
        assert third_line.endswith('Passed')
开发者ID:pre-commit,项目名称:pre-commit,代码行数:25,代码来源:install_uninstall_test.py


示例2: test_hook_install_failure

def test_hook_install_failure(mock_out_store_directory, tempdir_factory):
    git_path = make_consuming_repo(tempdir_factory, 'not_installable_repo')
    with cwd(git_path):
        install(Runner(git_path))

        # Don't want to write to home directory
        env = dict(os.environ, PRE_COMMIT_HOME=tempdir_factory.get())
        _, stdout, _ = cmd_output(
            'git', 'commit', '-m', 'Commit!',
            # git commit puts pre-commit to stderr
            stderr=subprocess.STDOUT,
            env=env,
            retcode=None,
            encoding=None,
        )
        assert b'UnicodeDecodeError' not in stdout
        # Doesn't actually happen, but a reasonable assertion
        assert b'UnicodeEncodeError' not in stdout

        # Sanity check our output
        assert (
            b'An unexpected error has occurred: CalledProcessError: ' in
            stdout
        )
        assert '☃'.encode('UTF-8') + '²'.encode('latin1') in stdout
开发者ID:bchess,项目名称:pre-commit,代码行数:25,代码来源:run_test.py


示例3: test_lots_of_files

def test_lots_of_files(mock_out_store_directory, tempdir_factory):
    # windows xargs seems to have a bug, here's a regression test for
    # our workaround
    git_path = make_consuming_repo(tempdir_factory, 'python_hooks_repo')
    with cwd(git_path):
        # Override files so we run against them
        with modify_config() as config:
            config[0]['hooks'][0]['files'] = ''

        # Write a crap ton of files
        for i in range(400):
            filename = '{0}{1}'.format('a' * 100, i)
            open(filename, 'w').close()

        cmd_output('bash', '-c', 'git add .')
        install(Runner(git_path))

        # Don't want to write to home directory
        env = dict(os.environ, PRE_COMMIT_HOME=tempdir_factory.get())
        cmd_output(
            'git', 'commit', '-m', 'Commit!',
            # git commit puts pre-commit to stderr
            stderr=subprocess.STDOUT,
            env=env,
        )
开发者ID:akramhussein,项目名称:pre-commit,代码行数:25,代码来源:run_test.py


示例4: in_merge_conflict

def in_merge_conflict(tmpdir_factory):
    path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
    with cwd(path):
        cmd_output('touch', 'dummy')
        cmd_output('git', 'add', 'dummy')
        cmd_output('git', 'add', C.CONFIG_FILE)
        cmd_output('git', 'commit', '-m', 'Add config.')

    conflict_path = tmpdir_factory.get()
    cmd_output('git', 'clone', path, conflict_path)
    with cwd(conflict_path):
        cmd_output('git', 'checkout', 'origin/master', '-b', 'foo')
        with io.open('conflict_file', 'w') as conflict_file:
            conflict_file.write('herp\nderp\n')
        cmd_output('git', 'add', 'conflict_file')
        with io.open('foo_only_file', 'w') as foo_only_file:
            foo_only_file.write('foo')
        cmd_output('git', 'add', 'foo_only_file')
        cmd_output('git', 'commit', '-m', 'conflict_file')
        cmd_output('git', 'checkout', 'origin/master', '-b', 'bar')
        with io.open('conflict_file', 'w') as conflict_file:
            conflict_file.write('harp\nddrp\n')
        cmd_output('git', 'add', 'conflict_file')
        with io.open('bar_only_file', 'w') as bar_only_file:
            bar_only_file.write('bar')
        cmd_output('git', 'add', 'bar_only_file')
        cmd_output('git', 'commit', '-m', 'conflict_file')
        cmd_output('git', 'merge', 'foo', retcode=None)
        yield os.path.join(conflict_path)
开发者ID:MMontgomeryII,项目名称:pre-commit,代码行数:29,代码来源:conftest.py


示例5: in_merge_conflict

def in_merge_conflict(tempdir_factory):
    path = make_consuming_repo(tempdir_factory, "script_hooks_repo")
    with cwd(path):
        cmd_output("touch", "dummy")
        cmd_output("git", "add", "dummy")
        cmd_output("git", "add", C.CONFIG_FILE)
        cmd_output("git", "commit", "-m", "Add config.")

    conflict_path = tempdir_factory.get()
    cmd_output("git", "clone", path, conflict_path)
    with cwd(conflict_path):
        cmd_output("git", "checkout", "origin/master", "-b", "foo")
        with io.open("conflict_file", "w") as conflict_file:
            conflict_file.write("herp\nderp\n")
        cmd_output("git", "add", "conflict_file")
        with io.open("foo_only_file", "w") as foo_only_file:
            foo_only_file.write("foo")
        cmd_output("git", "add", "foo_only_file")
        cmd_output("git", "commit", "-m", "conflict_file")
        cmd_output("git", "checkout", "origin/master", "-b", "bar")
        with io.open("conflict_file", "w") as conflict_file:
            conflict_file.write("harp\nddrp\n")
        cmd_output("git", "add", "conflict_file")
        with io.open("bar_only_file", "w") as bar_only_file:
            bar_only_file.write("bar")
        cmd_output("git", "add", "bar_only_file")
        cmd_output("git", "commit", "-m", "conflict_file")
        cmd_output("git", "merge", "foo", retcode=None)
        yield os.path.join(conflict_path)
开发者ID:imbstack,项目名称:pre-commit,代码行数:29,代码来源:conftest.py


示例6: test_environment_not_sourced

def test_environment_not_sourced(tempdir_factory, store):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(path):
        # Patch the executable to simulate rming virtualenv
        with mock.patch.object(sys, 'executable', '/does-not-exist'):
            assert install(C.CONFIG_FILE, store) == 0

        # Use a specific homedir to ignore --user installs
        homedir = tempdir_factory.get()
        ret, stdout, stderr = git_commit(
            env={
                'HOME': homedir,
                'PATH': _path_without_us(),
                # Git needs this to make a commit
                'GIT_AUTHOR_NAME': os.environ['GIT_AUTHOR_NAME'],
                'GIT_COMMITTER_NAME': os.environ['GIT_COMMITTER_NAME'],
                'GIT_AUTHOR_EMAIL': os.environ['GIT_AUTHOR_EMAIL'],
                'GIT_COMMITTER_EMAIL': os.environ['GIT_COMMITTER_EMAIL'],
            },
            retcode=None,
        )
        assert ret == 1
        assert stdout == ''
        assert stderr.replace('\r\n', '\n') == (
            '`pre-commit` not found.  '
            'Did you forget to activate your virtualenv?\n'
        )
开发者ID:pre-commit,项目名称:pre-commit,代码行数:27,代码来源:install_uninstall_test.py


示例7: test_environment_not_sourced

def test_environment_not_sourced(tmpdir_factory):
    path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
    with cwd(path):
        # Patch the executable to simulate rming virtualenv
        with mock.patch.object(sys, 'executable', '/bin/false'):
            assert install(Runner(path)) == 0

        # Use a specific homedir to ignore --user installs
        homedir = tmpdir_factory.get()
        # Need this so we can call git commit without sploding
        with io.open(os.path.join(homedir, '.gitconfig'), 'w') as gitconfig:
            gitconfig.write(
                '[user]\n'
                '    name = Travis CI\n'
                '    email = [email protected]\n'
            )
        ret, stdout, stderr = cmd_output(
            'git', 'commit', '--allow-empty', '-m', 'foo',
            env={'HOME': homedir},
            retcode=None,
        )
        assert ret == 1
        assert stdout == ''
        assert stderr == (
            '`pre-commit` not found.  '
            'Did you forget to activate your virtualenv?\n'
        )
开发者ID:rolka,项目名称:pre-commit,代码行数:27,代码来源:install_uninstall_test.py


示例8: test_hook_that_modifies_but_returns_zero

def test_hook_that_modifies_but_returns_zero(
        tempdir_factory, mock_out_store_directory,
):
    git_path = make_consuming_repo(
        tempdir_factory, 'modified_file_returns_zero_repo',
    )
    with cwd(git_path):
        stage_a_file('bar.py')
        _test_run(
            git_path,
            {},
            (
                # The first should fail
                b'Failed',
                # With a modified file (default message + the hook's output)
                b'Files were modified by this hook. Additional output:\n\n'
                b'Modified: foo.py',
                # The next hook should pass despite the first modifying
                b'Passed',
                # The next hook should fail
                b'Failed',
                # bar.py was modified, but provides no additional output
                b'Files were modified by this hook.\n',
            ),
            1,
            True,
        )
开发者ID:akramhussein,项目名称:pre-commit,代码行数:27,代码来源:run_test.py


示例9: test_failing_hooks_returns_nonzero

def test_failing_hooks_returns_nonzero(tmpdir_factory):
    path = make_consuming_repo(tmpdir_factory, 'failing_hook_repo')
    with cwd(path):
        assert install(Runner(path)) == 0

        ret, output = _get_commit_output(tmpdir_factory)
        assert ret == 1
        assert FAILING_PRE_COMMIT_RUN.match(output)
开发者ID:rolka,项目名称:pre-commit,代码行数:8,代码来源:install_uninstall_test.py


示例10: test_install_pre_commit_and_run

def test_install_pre_commit_and_run(tmpdir_factory):
    path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
    with cwd(path):
        assert install(Runner(path)) == 0

        ret, output = _get_commit_output(tmpdir_factory)
        assert ret == 0
        assert NORMAL_PRE_COMMIT_RUN.match(output)
开发者ID:rolka,项目名称:pre-commit,代码行数:8,代码来源:install_uninstall_test.py


示例11: test_legacy_overwriting_legacy_hook

def test_legacy_overwriting_legacy_hook(tempdir_factory, store):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(path):
        _write_legacy_hook(path)
        assert install(C.CONFIG_FILE, store) == 0
        _write_legacy_hook(path)
        # this previously crashed on windows.  See #1010
        assert install(C.CONFIG_FILE, store) == 0
开发者ID:pre-commit,项目名称:pre-commit,代码行数:8,代码来源:install_uninstall_test.py


示例12: test_installs_hooks_with_hooks_True

def test_installs_hooks_with_hooks_True(tmpdir_factory, mock_out_store_directory):
    path = make_consuming_repo(tmpdir_factory, "script_hooks_repo")
    with cwd(path):
        install(Runner(path), hooks=True)
        ret, output = _get_commit_output(tmpdir_factory, home=mock_out_store_directory)

        assert ret == 0
        assert PRE_INSTALLED.match(output)
开发者ID:Teino1978-Corp,项目名称:pre-commit,代码行数:8,代码来源:install_uninstall_test.py


示例13: test_install_overwrite_no_existing_hooks

def test_install_overwrite_no_existing_hooks(tmpdir_factory):
    path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
    with cwd(path):
        assert install(Runner(path), overwrite=True) == 0

        ret, output = _get_commit_output(tmpdir_factory)
        assert ret == 0
        assert NORMAL_PRE_COMMIT_RUN.match(output)
开发者ID:rolka,项目名称:pre-commit,代码行数:8,代码来源:install_uninstall_test.py


示例14: test_install_overwrite

def test_install_overwrite(tempdir_factory, store):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(path):
        _write_legacy_hook(path)
        assert install(C.CONFIG_FILE, store, overwrite=True) == 0

        ret, output = _get_commit_output(tempdir_factory)
        assert ret == 0
        assert NORMAL_PRE_COMMIT_RUN.match(output)
开发者ID:pre-commit,项目名称:pre-commit,代码行数:9,代码来源:install_uninstall_test.py


示例15: aliased_repo

def aliased_repo(tempdir_factory):
    git_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(git_path):
        with modify_config() as config:
            config['repos'][0]['hooks'].append(
                {'id': 'bash_hook', 'alias': 'foo_bash'},
            )
        stage_a_file()
        yield git_path
开发者ID:pre-commit,项目名称:pre-commit,代码行数:9,代码来源:run_test.py


示例16: test_types_hook_repository

def test_types_hook_repository(cap_out, store, tempdir_factory):
    git_path = make_consuming_repo(tempdir_factory, 'types_repo')
    with cwd(git_path):
        stage_a_file('bar.py')
        stage_a_file('bar.notpy')
        ret, printed = _do_run(cap_out, store, git_path, run_opts())
        assert ret == 1
        assert b'bar.py' in printed
        assert b'bar.notpy' not in printed
开发者ID:pre-commit,项目名称:pre-commit,代码行数:9,代码来源:run_test.py


示例17: test_install_pre_commit_and_run_custom_path

def test_install_pre_commit_and_run_custom_path(tempdir_factory, store):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(path):
        cmd_output('git', 'mv', C.CONFIG_FILE, 'custom-config.yaml')
        git_commit(cwd=path)
        assert install('custom-config.yaml', store) == 0

        ret, output = _get_commit_output(tempdir_factory)
        assert ret == 0
        assert NORMAL_PRE_COMMIT_RUN.match(output)
开发者ID:pre-commit,项目名称:pre-commit,代码行数:10,代码来源:install_uninstall_test.py


示例18: test_installs_hooks_with_hooks_True

def test_installs_hooks_with_hooks_True(tempdir_factory, store):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    with cwd(path):
        install(C.CONFIG_FILE, store, hooks=True)
        ret, output = _get_commit_output(
            tempdir_factory, pre_commit_home=store.directory,
        )

        assert ret == 0
        assert PRE_INSTALLED.match(output)
开发者ID:pre-commit,项目名称:pre-commit,代码行数:10,代码来源:install_uninstall_test.py


示例19: test_pre_push_integration_empty_push

def test_pre_push_integration_empty_push(tempdir_factory):
    upstream = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    path = tempdir_factory.get()
    cmd_output('git', 'clone', upstream, path)
    with cwd(path):
        install(Runner(path), hook_type='pre-push')
        _get_push_output(tempdir_factory)
        retc, output = _get_push_output(tempdir_factory)
        assert output == 'Everything up-to-date\n'
        assert retc == 0
开发者ID:hitul007,项目名称:pre-commit,代码行数:10,代码来源:install_uninstall_test.py


示例20: in_merge_conflict

def in_merge_conflict(tempdir_factory):
    path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
    open(os.path.join(path, 'dummy'), 'a').close()
    cmd_output('git', 'add', 'dummy', cwd=path)
    git_commit(msg=in_merge_conflict.__name__, cwd=path)

    conflict_path = tempdir_factory.get()
    cmd_output('git', 'clone', path, conflict_path)
    with cwd(conflict_path):
        _make_conflict()
        yield os.path.join(conflict_path)
开发者ID:pre-commit,项目名称:pre-commit,代码行数:11,代码来源:conftest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python fixtures.make_repo函数代码示例发布时间:2022-05-27
下一篇:
Python fixtures.make_config_from_repo函数代码示例发布时间: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