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

Python util.get_resource_path函数代码示例

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

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



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

示例1: test_img_conflict

def test_img_conflict(img_staged, cmd_runner):
    """Admittedly, this shouldn't happen, but just in case."""
    shutil.copy(get_resource_path('img2.jpg'), img_staged.img_filename)

    _test_img_state(img_staged, 'img2.jpg', 'AM')

    with staged_files_only(cmd_runner):
        _test_img_state(img_staged)
        shutil.copy(get_resource_path('img3.jpg'), img_staged.img_filename)
        _test_img_state(img_staged, 'img3.jpg', 'AM')

    _test_img_state(img_staged, 'img2.jpg', 'AM')
开发者ID:brettmcintosh,项目名称:pre-commit,代码行数:12,代码来源:staged_files_only_test.py


示例2: make_repo

def make_repo(tempdir_factory, repo_source):
    path = git_dir(tempdir_factory)
    copy_tree_to_path(get_resource_path(repo_source), path)
    with cwd(path):
        cmd_output('git', 'add', '.')
        cmd_output('git', 'commit', '-m', 'Add hooks')
    return path
开发者ID:Lucas-C,项目名称:pre-commit,代码行数:7,代码来源:fixtures.py


示例3: img_staged

def img_staged(tempdir_factory):
    path = git_dir(tempdir_factory)
    with cwd(path):
        img_filename = os.path.join(path, 'img.jpg')
        shutil.copy(get_resource_path('img1.jpg'), img_filename)
        cmd_output('git', 'add', 'img.jpg')
        yield auto_namedtuple(path=path, img_filename=img_filename)
开发者ID:brettmcintosh,项目名称:pre-commit,代码行数:7,代码来源:staged_files_only_test.py


示例4: make_repo

def make_repo(tmpdir_factory, repo_source):
    path = git_dir(tmpdir_factory)
    copy_tree_to_path(get_resource_path(repo_source), path)
    with local.cwd(path):
        git('add', '.')
        git('commit', '-m', 'Add hooks')
    return path
开发者ID:bukzor,项目名称:pre-commit,代码行数:7,代码来源:fixtures.py


示例5: _test_img_state

def _test_img_state(path, expected_file='img1.jpg', status='A'):
    assert os.path.exists(path.img_filename)
    with io.open(path.img_filename, 'rb') as f1:
        with io.open(get_resource_path(expected_file), 'rb') as f2:
            assert f1.read() == f2.read()
    actual_status = get_short_git_status()['img.jpg']
    assert status == actual_status
开发者ID:pre-commit,项目名称:pre-commit,代码行数:7,代码来源:staged_files_only_test.py


示例6: img_staged

def img_staged(tmpdir_factory):
    path = git_dir(tmpdir_factory)
    with local.cwd(path):
        img_filename = os.path.join(path, 'img.jpg')
        shutil.copy(get_resource_path('img1.jpg'), img_filename)
        local['git']('add', 'img.jpg')
        yield auto_namedtuple(path=path, img_filename=img_filename)
开发者ID:bukzor,项目名称:pre-commit,代码行数:7,代码来源:staged_files_only_test.py


示例7: test_detect_aws_credentials

def test_detect_aws_credentials(filename, expected_retval):
    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        '--credentials-file',
        'testing/resources/aws_config_with_multiple_sections.ini',
    ))
    assert ret == expected_retval
开发者ID:Harwood,项目名称:pre-commit-hooks,代码行数:8,代码来源:detect_aws_credentials_test.py


示例8: test_detect_aws_credentials

def test_detect_aws_credentials(filename, expected_retval):
    """Test if getting configured AWS secrets from files to be checked in works."""

    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        "--credentials-file=testing/resources/aws_config_with_multiple_sections.ini",
    ))
    assert ret == expected_retval
开发者ID:vinayinvicible,项目名称:pre-commit-hooks,代码行数:9,代码来源:detect_aws_credentials_test.py


示例9: test_img_something_unstaged

def test_img_something_unstaged(img_staged, cmd_runner):
    shutil.copy(get_resource_path('img2.jpg'), img_staged.img_filename)

    _test_img_state(img_staged, 'img2.jpg', 'AM')

    with staged_files_only(cmd_runner):
        _test_img_state(img_staged)

    _test_img_state(img_staged, 'img2.jpg', 'AM')
开发者ID:brettmcintosh,项目名称:pre-commit,代码行数:9,代码来源:staged_files_only_test.py


示例10: test_non_existent_credentials_with_allow_flag

def test_non_existent_credentials_with_allow_flag(mock_secrets_env, mock_secrets_file):
    """Test behavior with no configured AWS secrets and flag to allow when missing."""
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist",
        "--allow-missing-credentials",
    ))
    assert ret == 0
开发者ID:vinayinvicible,项目名称:pre-commit-hooks,代码行数:10,代码来源:detect_aws_credentials_test.py


示例11: test_non_existent_credentials_with_allow_flag

def test_non_existent_credentials_with_allow_flag(
        mock_secrets_env, mock_secrets_file,
):
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        '--credentials-file=testing/resources/credentailsfilethatdoesntexist',
        '--allow-missing-credentials',
    ))
    assert ret == 0
开发者ID:Harwood,项目名称:pre-commit-hooks,代码行数:11,代码来源:detect_aws_credentials_test.py


示例12: test_non_existent_credentials

def test_non_existent_credentials(capsys):
    # with a non-existent credentials file
    ret = main(
        (get_resource_path("with_secrets.txt"), "--credentials-file=testing/resources/credentailsfilethatdoesntexist")
    )
    assert ret == 2
    out, _ = capsys.readouterr()
    assert out == (
        "No aws keys were configured at "
        "testing/resources/credentailsfilethatdoesntexist\n"
        "Configure them with --credentials-file\n"
    )
开发者ID:CamZhou,项目名称:pre-commit-hooks,代码行数:12,代码来源:detect_aws_credentials_test.py


示例13: hook_disappearing_repo

def hook_disappearing_repo(tmpdir_factory):
    path = make_repo(tmpdir_factory, 'python_hooks_repo')
    original_sha = get_head_sha(path)

    with local.cwd(path):
        shutil.copy(
            get_resource_path('manifest_without_foo.yaml'),
            C.MANIFEST_FILE,
        )
        local['git']('add', '.')
        local['git']('commit', '-m', 'Remove foo')

    yield auto_namedtuple(path=path, original_sha=original_sha)
开发者ID:bukzor,项目名称:pre-commit,代码行数:13,代码来源:autoupdate_test.py


示例14: test_autofix_pretty_format_json

def test_autofix_pretty_format_json(tmpdir):
    srcfile = tmpdir.join('to_be_json_formatted.json')
    with io.open(get_resource_path('not_pretty_formatted_json.json')) as f:
        srcfile.write_text(f.read(), 'UTF-8')

    # now launch the autofix on that file
    ret = pretty_format_json(['--autofix', srcfile.strpath])
    # it should have formatted it
    assert ret == 1

    # file was formatted (shouldn't trigger linter again)
    ret = pretty_format_json([srcfile.strpath])
    assert ret == 0
开发者ID:dwaynebailey,项目名称:pre-commit-hooks,代码行数:13,代码来源:pretty_format_json_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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