Skip to content

Instantly share code, notes, and snippets.

@btamayo
Last active August 25, 2017 01:46
Show Gist options
  • Save btamayo/f66a5c1723b8288abbe5fe42bdfc0656 to your computer and use it in GitHub Desktop.
Save btamayo/f66a5c1723b8288abbe5fe42bdfc0656 to your computer and use it in GitHub Desktop.
Format string problem
# Template
TEST_TEMPLATE_RAW = """@test "{description} [{shell}]" {{
run ./{script_name} {shell} --debug --no-exec
{assert_type} {partial} {regexflag} "{expected}"
}}
# Codebit
# test is dumped in by pyyaml
print TEST_TEMPLATE_RAW.format(**test)
# Output
@test "Unknown command check 1.0 [bianca-blog.dev.app site.yml -b example-1 check list-hosts]" {
run ./ap.sh bianca-blog.dev.app site.yml -b example-1 check list-hosts --debug --no-exec
assert_failure ""
}
# Desired output (note the trimmed whitespace after assert_failure/getting rid of ""
@test "Unknown command check 1.0 [bianca-blog.dev.app site.yml -b example-1 check list-hosts]" {
run ./ap.sh bianca-blog.dev.app site.yml -b example-1 check list-hosts --debug --no-exec
assert_failure
}
# Test keys/vals (in yaml)
description: Unknown command check
playbook: site.yml
commands: -b example-1 check list-hosts
assert_type: assert_failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment