diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-06-15 19:02:36 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-06-15 19:02:36 +0000 |
commit | 7a2623ef27f686dfe802c62ece63911c56687261 (patch) | |
tree | 7c6206c151b4ec1784295df6c1b8a2c2f1020617 | |
parent | 833ae029d7bba7342e3abc9f9234f5a936816c30 (diff) | |
parent | 147858e8fad03d7ae2a96e3e5ff51d9abf5b2189 (diff) | |
download | cliff-7a2623ef27f686dfe802c62ece63911c56687261.tar.gz |
Merge "Add more test coverage for shell formatter"
-rw-r--r-- | cliff/tests/test_formatters_shell.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cliff/tests/test_formatters_shell.py b/cliff/tests/test_formatters_shell.py index e6813e5..956e16b 100644 --- a/cliff/tests/test_formatters_shell.py +++ b/cliff/tests/test_formatters_shell.py @@ -1,4 +1,7 @@ #!/usr/bin/env python + +import argparse + from six import StringIO, text_type from cliff.formatters import shell @@ -20,6 +23,21 @@ def test_shell_formatter(): assert expected == actual +def test_shell_formatter_args(): + sf = shell.ShellFormatter() + c = ('a', 'b', 'c', 'd') + d = ('A', 'B', 'C', '"escape me"') + expected = 'Xd="\\"escape me\\""\n' + output = StringIO() + # Parse arguments as if passed on the command-line + parser = argparse.ArgumentParser(description='Testing...') + sf.add_argument_group(parser) + parsed_args = parser.parse_args(['--variable', 'd', '--prefix', 'X']) + sf.emit_one(c, d, output, parsed_args) + actual = output.getvalue() + assert expected == actual + + def test_shell_formatter_with_non_string_values(): sf = shell.ShellFormatter() c = ('a', 'b', 'c', 'd', 'e') |