本文整理汇总了Python中utils.eq_函数的典型用法代码示例。如果您正苦于以下问题:Python eq_函数的具体用法?Python eq_怎么用?Python eq_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dict_contains
def dict_contains(superset, subset):
"""
Assert that all key/val pairs in dict 'subset' also exist in 'superset'
"""
for key, value in list(subset.items()):
ok_(key in superset)
eq_(superset[key], value)
示例2: test_get_relative_remote_dir_uses_home
def test_get_relative_remote_dir_uses_home(self):
"""
get('relative/path') should use remote $HOME
"""
with hide('everything'):
# Another if-it-doesn't-error-out-it-passed test; meh.
eq_(get('.bashrc', self.path()), [self.path('.bashrc')])
示例3: test_consecutive_sudos_should_not_have_blank_line
def test_consecutive_sudos_should_not_have_blank_line(self):
"""
Consecutive sudo() calls should not incur a blank line in-between
"""
env.password = None
env.no_agent = env.no_keys = True
env.key_filename = CLIENT_PRIVKEY
with password_response(
(CLIENT_PRIVKEY_PASSPHRASE, PASSWORDS[USER]),
silent=False
):
sudo('oneliner')
sudo('twoliner')
expected = """
[%(prefix)s] sudo: oneliner
[%(prefix)s] Login password for '%(user)s':
[%(prefix)s] out: sudo password:
[%(prefix)s] out: Sorry, try again.
[%(prefix)s] out: sudo password:
[%(prefix)s] out: result
[%(prefix)s] sudo: twoliner
[%(prefix)s] out: sudo password:
[%(prefix)s] out: result1
[%(prefix)s] out: result2
""" % {'prefix': env.host_string, 'user': env.user}
eq_(sys.stdall.getvalue(), expected[1:])
示例4: _prompt_display
def _prompt_display(display_output):
env.password = None
env.no_agent = env.no_keys = True
env.key_filename = CLIENT_PRIVKEY
output.output = display_output
with password_response(
(CLIENT_PRIVKEY_PASSPHRASE, PASSWORDS[env.user]),
silent=False
):
sudo('oneliner')
if display_output:
expected = """
[%(prefix)s] sudo: oneliner
[%(prefix)s] Login password for '%(user)s':
[%(prefix)s] out: sudo password:
[%(prefix)s] out: Sorry, try again.
[%(prefix)s] out: sudo password:
[%(prefix)s] out: result
""" % {'prefix': env.host_string, 'user': env.user}
else:
# Note lack of first sudo prompt (as it's autoresponded to) and of
# course the actual result output.
expected = """
[%(prefix)s] sudo: oneliner
[%(prefix)s] Login password for '%(user)s':
[%(prefix)s] out: Sorry, try again.
[%(prefix)s] out: sudo password: """ % {
'prefix': env.host_string,
'user': env.user
}
eq_(expected[1:], sys.stdall.getvalue())
示例5: test_silent_commands_should_not_have_blank_line
def test_silent_commands_should_not_have_blank_line(self):
"""
Silent commands should not generate an extra trailing blank line
After the move to interactive I/O, it was noticed that while run/sudo
commands which had non-empty stdout worked normally (consecutive such
commands were totally adjacent), those with no stdout (i.e. silent
commands like ``test`` or ``mkdir``) resulted in spurious blank lines
after the "run:" line. This looks quite ugly in real world scripts.
"""
env.password = None
env.no_agent = env.no_keys = True
env.key_filename = CLIENT_PRIVKEY
with password_response(CLIENT_PRIVKEY_PASSPHRASE, silent=False):
run('normal')
run('silent')
run('normal')
with hide('everything'):
run('normal')
run('silent')
expected = """
[%(prefix)s] run: normal
[%(prefix)s] Login password for '%(user)s':
[%(prefix)s] out: foo
[%(prefix)s] run: silent
[%(prefix)s] run: normal
[%(prefix)s] out: foo
""" % {'prefix': env.host_string, 'user': env.user}
eq_(expected[1:], sys.stdall.getvalue())
示例6: test_sudo_prompt_kills_capturing
def test_sudo_prompt_kills_capturing(self):
"""
Sudo prompts shouldn't screw up output capturing
"""
cmd = "ls /simple"
with hide('everything'):
eq_(sudo(cmd), RESPONSES[cmd])
示例7: test_should_return_dict_for_base_case
def test_should_return_dict_for_base_case(self):
"""
Non-network-related tasks should return a dict w/ special key
"""
def task():
return "foo"
eq_(execute(task), {'<local-only>': 'foo'})
示例8: test_flat_alias
def test_flat_alias(self):
f = fabfile("flat_alias.py")
with path_prefix(f):
docs, funcs = load_fabfile(f)
eq_(len(funcs), 2)
ok_("foo" in funcs)
ok_("foo_aliased" in funcs)
示例9: test_put_returns_list_of_remote_paths_with_stringio
def test_put_returns_list_of_remote_paths_with_stringio(self):
"""
put() should return a one-item iterable when uploading from a StringIO
"""
f = 'uploaded.txt'
with hide('everything'):
eq_(put(StringIO('contents'), f), [f])
示例10: test_multiline_docstring_indented_correctly
def test_multiline_docstring_indented_correctly(self):
"""
display_command() should properly indent docstr for old style task methods
"""
def mytask(arg1):
"""
This is a multi line docstring.
For reals.
"""
try:
with patched_context(fabric.state, 'commands', {'mytask': mytask}):
display_command('mytask')
except SystemExit: # ugh
pass
eq_(
sys.stdout.getvalue(),
"""Displaying detailed information for task 'mytask':
This is a multi line docstring.
For reals.
Arguments: arg1
"""
)
示例11: test_prompt_appends_space
def test_prompt_appends_space():
"""
prompt() appends a single space when no default is given
"""
s = "This is my prompt"
prompt(s)
eq_(sys.stdout.getvalue(), s + ' ')
示例12: test_passes_all_regular_args_to_run
def test_passes_all_regular_args_to_run(self):
def foo(*args): return args
random_args = tuple(
[random.randint(1000, 2000) for i in range(random.randint(1, 5))]
)
task = WrappedCallableTask(foo)
eq_(random_args, task(*random_args))
示例13: test_at_symbol_in_username
def test_at_symbol_in_username(self):
"""
normalize() should allow '@' in usernames (i.e. last '@' is split char)
"""
parts = normalize('[email protected]@www.example.com')
eq_(parts[0], '[email protected]')
eq_(parts[1], 'www.example.com')
示例14: test_parallel
def test_parallel(self):
"""
Want to do a simple call and respond
"""
env.pool_size = 10
cmd = "ls /simple"
with hide('everything'):
eq_(run(cmd), RESPONSES[cmd])
示例15: test_sudo_prefix_with_user_and_group
def test_sudo_prefix_with_user_and_group():
"""
_sudo_prefix() returns prefix plus -u and -g for nonempty user and group
"""
eq_(
_sudo_prefix(user="foo", group="bar"),
"%s -u \"foo\" -g \"bar\" " % (env.sudo_prefix % env)
)