summaryrefslogtreecommitdiff
path: root/tests/test_transcript.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 14:47:11 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 14:47:11 -0500
commit0a518f07562bdccc7c0d000d34dab225ef919e65 (patch)
treeeee22de27f99e5023439e3653430c5655f532204 /tests/test_transcript.py
parent71d7465c570ea98f6df4ca6b4e88f10c77f4eba0 (diff)
downloadcmd2-git-0a518f07562bdccc7c0d000d34dab225ef919e65.tar.gz
Added unit test for passing command line arguments at invocation
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r--tests/test_transcript.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index 8b38c671..a4102bc8 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -5,8 +5,10 @@ Cmd2 functional testing based on transcript
Copyright 2016 Federico Ceratto <federico.ceratto@gmail.com>
Released under MIT license, see LICENSE file
"""
+import sys
import pytest
+from mock import patch
from cmd2 import Cmd, make_option, options, Cmd2TestCase
from conftest import run_cmd, StdOut, normalize
@@ -212,4 +214,14 @@ def test_optarser_options_with_spaces_in_quotes(_demo_app):
assert out == expected
+def test_commands_at_invocation(_cmdline_app):
+ testargs = ["prog", "say hello", "say Gracie", "quit"]
+ expected = "hello\nGracie\n"
+ with patch.object(sys, 'argv', testargs):
+ app = CmdLineApp()
+ app.stdout = StdOut()
+ app.cmdloop()
+ out = app.stdout.buffer
+ assert out == expected
+