本文整理汇总了Python中utils.assert_contains函数的典型用法代码示例。如果您正苦于以下问题:Python assert_contains函数的具体用法?Python assert_contains怎么用?Python assert_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_contains函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_error_includes_stderr_if_given_and_hidden
def test_error_includes_stderr_if_given_and_hidden(self):
"""
error() correctly prints stderr if it was previously hidden
"""
# Mostly to catch regression bug(s)
stderr = "this is my stderr"
with hide('stderr'):
error("error message", func=utils.abort, stderr=stderr)
assert_contains(stderr, sys.stderr.getvalue())
示例2: test_password_prompt_displays_host_string
def test_password_prompt_displays_host_string(self):
"""
Password prompt lines should include the user/host in question
"""
env.password = None
env.no_agent = env.no_keys = True
with show('everything'), password_response(PASSWORDS[env.user], silent=False):
run("ls /simple")
regex = r'^\[%s\] Login password for \'%s\': ' % (env.host_string, env.user)
assert_contains(regex, sys.stderr.getvalue())
示例3: test_passphrase_prompt_displays_host_string
def test_passphrase_prompt_displays_host_string(self):
"""
Passphrase prompt lines should include the user/host in question
"""
env.password = None
env.no_agent = env.no_keys = True
env.key_filename = CLIENT_PRIVKEY
with hide('everything'), password_response(CLIENT_PRIVKEY_PASSPHRASE, silent=False):
run("ls /simple")
regex = r'^\[%s\] Login password for \'%s\': ' % (env.host_string, env.user)
assert_contains(regex, sys.stderr.getvalue())
示例4: _invalid_file_obj_situations
def _invalid_file_obj_situations(self, remote_path):
with settings(hide('running'), warn_only=True):
get(remote_path, StringIO())
assert_contains('is a glob or directory', sys.stderr.getvalue())
示例5: test_includes_traceback_if_debug_logging_is_on
def test_includes_traceback_if_debug_logging_is_on(self):
"""
error() includes traceback in message if debug logging is on (backwardis compatibility)
"""
error("error message", func=utils.abort, stdout=error)
assert_contains(self.dummy_string, sys.stdout.getvalue())
示例6: test_includes_traceback_if_exceptions_logging_is_on
def test_includes_traceback_if_exceptions_logging_is_on(self):
"""
error() includes traceback in message if exceptions logging is on
"""
error("error message", func=utils.abort, stdout=error)
assert_contains(self.dummy_string, sys.stdout.getvalue())
示例7: print_header
#
print_header("3.2 Remove X Windows (Scored)")
# Original CIS test
# check_equal(
# 'grep "^id:" /etc/inittab',
# "id:3:initdefault"
# )
# Syco hardened servers use this.
check_equal(
'grep "^\~\~\:S\:wait\:\/sbin\/sulogin" /etc/inittab',
"~~:S:wait:/sbin/sulogin"
)
result = x('yum grouplist "X Window System"')
max_lines = len(result)
assert_contains(result[max_lines-3], "Available Groups:")
assert_contains(result[max_lines-2], " X Window System")
assert_contains(result[max_lines-1], "Done")
#
print_header("3.3 Disable Avahi Server (Scored)")
check_equal(
"rpm -q avahi",
"package avahi is not installed"
)
check_empty("chkconfig --list | grep avahi")
#
print_header("3.4 Disable Print Server - CUPS (Not Scored)")
check_equal(
"rpm -q cups",