本文整理汇总了Python中utils.eq_contents函数的典型用法代码示例。如果您正苦于以下问题:Python eq_contents函数的具体用法?Python eq_contents怎么用?Python eq_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_single_file_in_folder
def test_get_single_file_in_folder(self):
"""
get() a folder containing one file
"""
remote = 'folder/file3.txt'
with hide('everything'):
get('folder', self.tmpdir)
eq_contents(self.path(remote), FILES[remote])
示例2: test_get_single_file_absolutely
def test_get_single_file_absolutely(self):
"""
get() a single file, using absolute file path
"""
target = '/etc/apache2/apache2.conf'
with hide('everything'):
get(target, self.tmpdir)
eq_contents(self.path(os.path.basename(target)), FILES[target])
示例3: test_get_tree
def test_get_tree(self):
"""
Download entire tree
"""
with hide('everything'):
get('tree', self.tmpdir)
leaves = filter(lambda x: x[0].startswith('/tree'), FILES.items())
for path, contents in leaves:
eq_contents(self.path(path[1:]), contents)
示例4: test_get_tree
def test_get_tree(self):
"""
Download entire tree
"""
with hide('everything'):
get('tree', self.tmpdir)
leaves = [x for x in list(FILES.items()) if x[0].startswith('/tree')]
for path, contents in leaves:
eq_contents(self.path(path[1:]), contents)
示例5: test_get_sibling_globs
def test_get_sibling_globs(self):
"""
get() with globbed files, but no directories
"""
remotes = ['file.txt', 'file2.txt']
with hide('everything'):
get('file*.txt', self.tmpdir)
for remote in remotes:
eq_contents(self.path(remote), FILES[remote])
示例6: test_get_single_file
def test_get_single_file(self):
"""
get() with a single non-globbed filename
"""
remote = 'file.txt'
local = self.path(remote)
with hide('everything'):
get(remote, local)
eq_contents(local, FILES[remote])
示例7: test_get_file_with_nonexistent_target
def test_get_file_with_nonexistent_target(self):
"""
Missing target path on single file download => effectively a rename
"""
local = self.path('otherfile.txt')
target = 'file.txt'
with hide('everything'):
get(target, local)
eq_contents(local, FILES[target])
示例8: test_get_file_to_directory
def test_get_file_to_directory(self):
"""
Directory as target path should result in joined pathname
(Yes, this is duplicated in most of the other tests -- but good to have
a default in case those tests change how they work later!)
"""
target = 'file.txt'
with hide('everything'):
get(target, self.tmpdir)
eq_contents(self.path(target), FILES[target])
示例9: test_put_file_to_existing_directory
def test_put_file_to_existing_directory(self):
"""
put() a single file into an existing remote directory
"""
text = "foo!"
local = self.mkfile('foo.txt', text)
local2 = self.path('foo2.txt')
with hide('everything'):
put(local, '/')
get('/foo.txt', local2)
eq_contents(local2, text)
示例10: test_put_sends_correct_file_with_globbing_off
def test_put_sends_correct_file_with_globbing_off(self):
"""
put() should send a file with a glob pattern in the path, when globbing disabled.
"""
text = "globbed!"
local = self.mkfile('foo[bar].txt', text)
local2 = self.path('foo2.txt')
with hide('everything'):
put(local, '/', use_glob=False)
get('/foo[bar].txt', local2)
eq_contents(local2, text)
示例11: test_upload_template_handles_file_destination
def test_upload_template_handles_file_destination(self):
"""
upload_template() should work OK with file and directory destinations
"""
template = self.mkfile('template.txt', '%(varname)s')
local = self.path('result.txt')
remote = '/configfile.txt'
var = 'foobar'
with hide('everything'):
upload_template(template, remote, {'varname': var})
get(remote, local)
eq_contents(local, var)
示例12: test_get_file_with_existing_file_target
def test_get_file_with_existing_file_target(self):
"""
Clobbering existing local file should overwrite, with warning
"""
local = self.path('target.txt')
target = 'file.txt'
with open(local, 'w') as fd:
fd.write("foo")
with hide('stdout', 'running'):
get(target, local)
assert "%s already exists" % local in sys.stderr.getvalue()
eq_contents(local, FILES[target])
示例13: test_upload_template_handles_template_dir
def test_upload_template_handles_template_dir(self):
"""
upload_template() should work OK with template dir
"""
template = self.mkfile("template.txt", "%(varname)s")
template_dir = os.path.dirname(template)
local = self.path("result.txt")
remote = "/configfile.txt"
var = "foobar"
with hide("everything"):
upload_template("template.txt", remote, {"varname": var}, template_dir=template_dir)
get(remote, local)
eq_contents(local, var)
示例14: test_put_should_accept_file_like_objects
def test_put_should_accept_file_like_objects(self):
"""
put()'s local_path arg should take file-like objects too
"""
local = self.path('whatever')
fake_file = StringIO()
fake_file.write("testing file-like objects in put()")
pointer = fake_file.tell()
target = '/new_file.txt'
with hide('everything'):
put(fake_file, target)
get(target, local)
eq_contents(local, fake_file.getvalue())
# Sanity test of file pointer
eq_(pointer, fake_file.tell())
示例15: test_upload_template_handles_jinja_template
def test_upload_template_handles_jinja_template(self):
"""
upload_template() should work OK with Jinja2 template
"""
template = self.mkfile('template_jinja2.txt', '{{ first_name }}')
template_name = os.path.basename(template)
template_dir = os.path.dirname(template)
local = self.path('result.txt')
remote = '/configfile.txt'
first_name = u'S\u00E9bastien'
with hide('everything'):
upload_template(template_name, remote, {'first_name': first_name},
use_jinja=True, template_dir=template_dir)
get(remote, local)
eq_contents(local, first_name.encode('utf-8'))