本文整理汇总了Python中shared.assert_contents函数的典型用法代码示例。如果您正苦于以下问题:Python assert_contents函数的具体用法?Python assert_contents怎么用?Python assert_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_contents函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_import_with_gitignore
def test_import_with_gitignore(self):
# Make sure our git imports don't get confused by .gitignore files.
new_content = {"fee/fi": "fo fum", ".gitignore": "fee/"}
new_tree = self.cache.import_tree(shared.create_dir(new_content))
export_dir = shared.create_dir()
self.cache.export_tree(new_tree, export_dir)
assert_contents(export_dir, new_content)
开发者ID:Arvindhm,项目名称:peru,代码行数:7,代码来源:test_cache.py
示例2: test_import_with_gitignore
def test_import_with_gitignore(self):
# Make sure our git imports don't get confused by .gitignore files.
new_content = {'fee/fi': 'fo fum', '.gitignore': 'fee/'}
new_tree = yield from self.cache.import_tree(create_dir(new_content))
export_dir = create_dir()
yield from self.cache.export_tree(new_tree, export_dir)
assert_contents(export_dir, new_content)
开发者ID:jmbrads22,项目名称:peru,代码行数:7,代码来源:test_cache.py
示例3: do_integration_test
def do_integration_test(self, args, expected, *, cwd=None,
**peru_cmd_kwargs):
if not cwd:
cwd = self.test_dir
run_peru_command(args, cwd, **peru_cmd_kwargs)
assert_contents(self.test_dir, expected,
excludes=[DEFAULT_PERU_FILE_NAME, '.peru'])
开发者ID:eramosfigueroa,项目名称:peru-1,代码行数:7,代码来源:test_sync.py
示例4: do_plugin_test
def do_plugin_test(self, type, plugin_fields, expected_content, *,
fetch_dir=None):
fetch_dir = fetch_dir or shared.create_dir()
output = test_plugin_fetch(
self.plugin_context, type, plugin_fields, fetch_dir)
assert_contents(fetch_dir, expected_content)
return output
开发者ID:oconnor663,项目名称:peru,代码行数:7,代码来源:test_plugins.py
示例5: test_reup_all
def test_reup_all(self):
yaml_with_imports = dedent('''\
imports:
foo: ./
bar: ./
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
''').format(self.foo_dir, self.foo_master, self.bar_dir)
test_dir = shared.create_dir({'peru.yaml': yaml_with_imports})
expected = dedent('''\
imports:
foo: ./
bar: ./
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
rev: {}
''').format(self.foo_dir, self.foo_master, self.bar_dir,
self.bar_otherbranch)
run_peru_command(['reup'], test_dir)
# This time we finally pull in barfile.
assert_contents(test_dir,
{'peru.yaml': expected, 'a': 'b', 'barfile': 'new'},
excludes=['.peru'])
开发者ID:emgee,项目名称:peru,代码行数:35,代码来源:test_reup.py
示例6: test_executable
def test_executable(self):
exe = yield from rule.make_files_executable(self.cache, self.content_tree, ["b/*"])
new_content_dir = shared.create_dir()
yield from self.cache.export_tree(exe, new_content_dir)
shared.assert_contents(new_content_dir, self.content)
shared.assert_not_executable(os.path.join(new_content_dir, "a"))
shared.assert_executable(os.path.join(new_content_dir, "b/c"))
开发者ID:emgee,项目名称:peru,代码行数:7,代码来源:test_rule.py
示例7: test_executable
async def test_executable(self):
exe = await rule.make_files_executable(self.cache, self.content_tree,
['b/*'])
new_content_dir = shared.create_dir()
await self.cache.export_tree(exe, new_content_dir)
shared.assert_contents(new_content_dir, self.content)
shared.assert_not_executable(os.path.join(new_content_dir, 'a'))
shared.assert_executable(os.path.join(new_content_dir, 'b/c'))
开发者ID:buildinspace,项目名称:peru,代码行数:8,代码来源:test_rule.py
示例8: do_plugin_test
def do_plugin_test(self, type, plugin_fields, expected_content, *,
hide_stderr=False):
fetch_dir = shared.create_dir()
output = plugin_fetch(
self.plugin_context, type, plugin_fields, fetch_dir,
capture_output=True, stderr_to_stdout=hide_stderr)
assert_contents(fetch_dir, expected_content)
return output
开发者ID:mgartner,项目名称:peru,代码行数:8,代码来源:test_plugins.py
示例9: test_merge_from_map
def test_merge_from_map(self):
imports = {'foo': ('path1',), 'bar': ('path2',)}
target_trees = {'foo': self.content_tree, 'bar': self.content_tree}
merged_tree = merge_imports_tree(self.cache, imports, target_trees)
merged_dir = create_dir()
self.cache.export_tree(merged_tree, merged_dir)
expected_content = {'path1/a': 'a', 'path2/a': 'a'}
assert_contents(merged_dir, expected_content)
开发者ID:enzochiau,项目名称:peru,代码行数:10,代码来源:test_merge.py
示例10: test_unpack_windows_zip
def test_unpack_windows_zip(self):
'''This zip was packed on Windows, so it doesn't include any file
permissions. This checks that our executable-flag-restoring code
doesn't barf when the flag isn't there.'''
test_dir = shared.create_dir()
archive = shared.test_resources / 'from_windows.zip'
curl_plugin.extract_zip(str(archive), test_dir)
shared.assert_contents(test_dir, {'windows_test/test.txt': 'Notepad!'})
txt_file = join(test_dir, 'windows_test/test.txt')
shared.assert_not_executable(txt_file)
开发者ID:enzochiau,项目名称:peru,代码行数:10,代码来源:test_curl_plugin.py
示例11: test_export_force_with_preexisting_files
async def test_export_force_with_preexisting_files(self):
# Create a working tree with a conflicting file.
dirty_content = {'a': 'junk'}
export_dir = create_dir(dirty_content)
# Export should fail by default.
with self.assertRaises(peru.cache.DirtyWorkingCopyError):
await self.cache.export_tree(self.content_tree, export_dir)
assert_contents(export_dir, dirty_content)
# But it should suceed with the force flag.
await self.cache.export_tree(self.content_tree, export_dir, force=True)
assert_contents(export_dir, self.content)
开发者ID:buildinspace,项目名称:peru,代码行数:11,代码来源:test_cache.py
示例12: test_merge_with_deep_prefix
def test_merge_with_deep_prefix(self):
'''This test was inspired by a bug on Windows where we would give git a
backslash-separated merge prefix, even though git demands forward slash
as a path separator.'''
content = {'file': 'stuff'}
content_dir = create_dir(content)
tree = yield from self.cache.import_tree(content_dir)
prefixed_tree = yield from self.cache.merge_trees(None, tree, 'a/b/')
export_dir = create_dir()
yield from self.cache.export_tree(prefixed_tree, export_dir)
assert_contents(export_dir, {'a/b/file': 'stuff'})
开发者ID:jmbrads22,项目名称:peru,代码行数:11,代码来源:test_cache.py
示例13: test_import_with_files
def test_import_with_files(self):
all_content = {'foo': '',
'bar': '',
'baz/bing': ''}
test_dir = create_dir(all_content)
tree = self.cache.import_tree(test_dir, picks=['foo', 'baz'])
expected_content = {'foo': '',
'baz/bing': ''}
out_dir = create_dir()
self.cache.export_tree(tree, out_dir)
assert_contents(out_dir, expected_content)
开发者ID:enzochiau,项目名称:peru,代码行数:11,代码来源:test_cache.py
示例14: test_missing_files_in_previous_tree
def test_missing_files_in_previous_tree(self):
'''Export should allow missing files, and it should recreate them.'''
export_dir = create_dir()
# Nothing in content_tree exists yet, so this export should be the same
# as if previous_tree wasn't specified.
yield from self.cache.export_tree(
self.content_tree, export_dir, previous_tree=self.content_tree)
assert_contents(export_dir, self.content)
# Make sure the same applies with just a single missing file.
os.remove(os.path.join(export_dir, 'a'))
yield from self.cache.export_tree(
self.content_tree, export_dir, previous_tree=self.content_tree)
assert_contents(export_dir, self.content)
开发者ID:jmbrads22,项目名称:peru,代码行数:13,代码来源:test_cache.py
示例15: test_single_reup
def test_single_reup(self):
expected = dedent('''\
git module foo:
url: {}
rev: {}
git module bar:
url: {}
reup: otherbranch
''').format(self.foo_dir, self.foo_master, self.bar_dir)
run_peru_command(['reup', 'foo'], self.test_dir)
assert_contents(self.test_dir, {'peru.yaml': expected},
excludes=['.peru'])
开发者ID:mgartner,项目名称:peru,代码行数:13,代码来源:test_reup.py
示例16: test_export_force_with_changed_files
def test_export_force_with_changed_files(self):
export_dir = create_dir()
self.cache.export_tree(self.content_tree, export_dir)
# If we dirty a file, a resync should fail.
with open(os.path.join(export_dir, 'a'), 'w') as f:
f.write('dirty')
with self.assertRaises(peru.cache.DirtyWorkingCopyError):
self.cache.export_tree(self.content_tree, export_dir,
previous_tree=self.content_tree)
# But it should succeed with the --force flag.
self.cache.export_tree(self.content_tree, export_dir, force=True,
previous_tree=self.content_tree)
assert_contents(export_dir, self.content)
开发者ID:enzochiau,项目名称:peru,代码行数:13,代码来源:test_cache.py
示例17: test_merge_trees
def test_merge_trees(self):
merged_tree = yield from self.cache.merge_trees(
self.content_tree, self.content_tree, 'subdir')
expected_content = dict(self.content)
for path, content in self.content.items():
expected_content[os.path.join('subdir', path)] = content
export_dir = create_dir()
yield from self.cache.export_tree(merged_tree, export_dir)
assert_contents(export_dir, expected_content)
with self.assertRaises(peru.cache.MergeConflictError):
# subdir/ is already populated, so this merge should throw.
yield from self.cache.merge_trees(
merged_tree, self.content_tree, 'subdir')
开发者ID:jmbrads22,项目名称:peru,代码行数:14,代码来源:test_cache.py
示例18: test_merge_from_list
def test_merge_from_list(self):
# This represents a list of key-value pairs in YAML, for example:
# imports:
# - foo: path1
# - foo: path2
imports_list = [{'foo': 'path1'}, {'foo': 'path2'}]
imports = build_imports(imports_list)
target_trees = {'foo': self.content_tree}
merged_tree = merge_imports_tree(self.cache, imports, target_trees)
merged_dir = create_dir()
self.cache.export_tree(merged_tree, merged_dir)
expected_content = {'path1/a': 'a', 'path2/a': 'a'}
assert_contents(merged_dir, expected_content)
开发者ID:Arvindhm,项目名称:peru,代码行数:15,代码来源:test_merge.py
示例19: test_merge_from_multimap
def test_merge_from_multimap(self):
# This represents a list of key-value pairs in YAML, for example:
# imports:
# foo:
# - path1
# - path2
imports = {'foo': ('path1', 'path2')}
target_trees = {'foo': self.content_tree}
merged_tree = merge_imports_tree(self.cache, imports, target_trees)
merged_dir = create_dir()
self.cache.export_tree(merged_tree, merged_dir)
expected_content = {'path1/a': 'a', 'path2/a': 'a'}
assert_contents(merged_dir, expected_content)
开发者ID:enzochiau,项目名称:peru,代码行数:15,代码来源:test_merge.py
示例20: test_sync_from_subdir
def test_sync_from_subdir(self):
peru_yaml = dedent('''\
# Use a relative module path, to make sure it gets resolved
# relative to the project root and not the dir where peru was
# called.
cp module relative_foo:
path: {}
imports:
relative_foo: subdir
'''.format(os.path.relpath(self.module_dir, start=self.test_dir)))
shared.write_files(self.test_dir, {'peru.yaml': peru_yaml})
subdir = os.path.join(self.test_dir, 'a', 'b')
peru.compat.makedirs(subdir)
run_peru_command(['sync'], subdir)
self.assertTrue(os.path.isdir(os.path.join(self.test_dir, '.peru')),
msg=".peru dir didn't end up in the right place")
assert_contents(os.path.join(self.test_dir, 'subdir'), {'foo': 'bar'})
开发者ID:Arvindhm,项目名称:peru,代码行数:18,代码来源:test_sync.py
注:本文中的shared.assert_contents函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论