本文整理汇总了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;未经允许,请勿转载。 |
请发表评论