summaryrefslogtreecommitdiff
path: root/tests/test_transcript.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r--tests/test_transcript.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index aefd0068..2c717f58 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -43,6 +43,17 @@ class CmdLineApp(Cmd):
do_orate = do_speak # another synonym, but this one takes multi-line input
+class DemoApp(Cmd):
+ @options([make_option('-n', '--name', action="store", help="your name"),
+ ])
+ def do_hello(self, arg, opts):
+ """Says hello."""
+ if opts.name:
+ self.stdout.write('Hello {}\n'.format(opts.name))
+ else:
+ self.stdout.write('Hello Nobody\n')
+
+
@pytest.fixture
def _cmdline_app():
c = CmdLineApp()
@@ -52,6 +63,13 @@ def _cmdline_app():
return c
+@pytest.fixture
+def _demo_app():
+ c = DemoApp()
+ c.stdout = StdOut()
+ return c
+
+
def _get_transcript_blocks(transcript):
cmd = None
expected = ''
@@ -176,16 +194,21 @@ Options:
assert _normalize(str(out)) == expected
-def test_comment_stripping(_cmdline_app, capsys):
+def test_comment_stripping(_cmdline_app):
out = run_cmd(_cmdline_app, 'speak it was /* not */ delicious! # Yuck!')
expected = _normalize("""it was delicious!""")
assert out == expected
-def test_optarser_correct_args_with_quotes_and_midline_options(_cmdline_app, capsys):
+def test_optarser_correct_args_with_quotes_and_midline_options(_cmdline_app):
out = run_cmd(_cmdline_app, "speak 'This is a' -s test of the emergency broadcast system!")
expected = _normalize("""THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM!""")
assert out == expected
+def test_optarser_options_with_spaces_in_quotes(_demo_app):
+ out = run_cmd(_demo_app, "hello foo -n 'Bugs Bunny' bar baz")
+ expected = _normalize("""Hello Bugs Bunny""")
+ assert out == expected
+