本文整理汇总了Python中shared.assert_contents函数的典型用法代码示例。如果您正苦于以下问题:Python assert_contents函数的具体用法?Python assert_contents怎么用?Python assert_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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'])
示例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
示例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'])
示例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"))
示例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'))
示例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
示例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)
示例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)
示例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)
示例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'})
示例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)
示例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)
示例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'])