Exemplo n.º 1
0
def step_file_should_contain_text(context, filename, text):
    expected_text = text
    if "{__WORKDIR__}" in text or "{__CWD__}" in text or "{__HOME__}" in text:
        expected_text = textutil.template_substitute(
            text,
            __WORKDIR__=posixpath_normpath(context.workdir),
            __CWD__=posixpath_normpath(os.getcwd()),
            __HOME__=posixpath_normpath(os.path.expanduser('~')))
    file_contents = pathutil.read_file_contents(filename, context=context)
    file_contents = file_contents.rstrip()
    if DEBUG:
        print(u"expected:\n{0}".format(expected_text))
        print(u"actual:\n{0}".format(file_contents))
    textutil.assert_normtext_should_contain(file_contents, expected_text)
def step_file_should_contain_text(context, filename, text):
    expected_text = text
    if "{__WORKDIR__}" in text or "{__CWD__}" in text or "{__HOME__}" in text:
        expected_text = textutil.template_substitute(text,
            __WORKDIR__ = posixpath_normpath(context.workdir),
            __CWD__     = posixpath_normpath(os.getcwd()),
            __HOME__    = posixpath_normpath(os.path.expanduser('~'))
        )
    file_contents = pathutil.read_file_contents(filename, context=context)
    file_contents = file_contents.rstrip()
    if DEBUG:
        print(u"expected:\n{0}".format(expected_text))
        print(u"actual:\n{0}".format(file_contents))
    textutil.assert_normtext_should_contain(file_contents, expected_text)
Exemplo n.º 3
0
def step_command_output_should_contain_text(context, text):
    '''
    EXAMPLE:
        ...
        Then the command output should contain "TEXT"
    '''
    expected_text = text
    if "{__WORKDIR__}" in text or "{__CWD__}" in text or "{__HOME__}" in text:
        expected_text = textutil.template_substitute(
            text,
            __WORKDIR__=posixpath_normpath(context.workdir),
            __CWD__=posixpath_normpath(os.getcwd()),
            __HOME__=posixpath_normpath(os.path.expanduser('~')))
    actual_output = context.command_result.output
    if DEBUG:
        print(u"expected:\n{0}".format(expected_text))
        print(u"actual:\n{0}".format(actual_output))
    textutil.assert_normtext_should_contain(actual_output, expected_text)
def step_command_output_should_contain_text(context, text):
    '''
    EXAMPLE:
        ...
        Then the command output should contain "TEXT"
    '''
    expected_text = text
    if "{__WORKDIR__}" in text or "{__CWD__}" in text or "{__HOME__}" in text:
        expected_text = textutil.template_substitute(text,
            __WORKDIR__ = posixpath_normpath(context.workdir),
            __CWD__     = posixpath_normpath(os.getcwd()),
            __HOME__    = posixpath_normpath(os.path.expanduser('~'))
        )
    actual_output = context.command_result.output
    if DEBUG:
        print(u"expected:\n{0}".format(expected_text))
        print(u"actual:\n{0}".format(actual_output))
    textutil.assert_normtext_should_contain(actual_output, expected_text)