summaryrefslogtreecommitdiff
path: root/tests/test_transcript.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-01-29 23:20:19 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-01-29 23:20:19 -0500
commit16e3cdda9d4c1176246f1e9f9764a789a263814c (patch)
treec83f04e580581b07dce9d71916175ac9be9465b6 /tests/test_transcript.py
parent95c5ceee69720e51f20f6b02d457936768cc154e (diff)
downloadcmd2-git-16e3cdda9d4c1176246f1e9f9764a789a263814c.tar.gz
Added a couple simple unit tests for optparser functionality
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r--tests/test_transcript.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index 253b338d..69647148 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -137,6 +137,39 @@ now: --->
assert out == expected
+def test_optparser(_cmdline_app, capsys):
+ run_cmd(_cmdline_app, 'say -h')
+ out, err = capsys.readouterr()
+ expected = _normalize("""
+Repeats what you tell me to.
+Usage: speak [options] (text to say)
+
+Options:
+ -h, --help show this help message and exit
+ -p, --piglatin atinLay
+ -s, --shout N00B EMULATION MODE
+ -r REPEAT, --repeat=REPEAT
+ output [n] times""")
+ assert _normalize(out) == expected
+
+
+def test_optparser_nosuchoption(_cmdline_app, capsys):
+ run_cmd(_cmdline_app, 'say -a')
+ out, err = capsys.readouterr()
+ expected = _normalize("""
+no such option: -a
+Repeats what you tell me to.
+Usage: speak [options] (text to say)
+
+Options:
+ -h, --help show this help message and exit
+ -p, --piglatin atinLay
+ -s, --shout N00B EMULATION MODE
+ -r REPEAT, --repeat=REPEAT
+ output [n] times""")
+ assert _normalize(out) == expected
+
+
class TestMyAppCase(Cmd2TestCase):
CmdApp = CmdLineApp
CmdApp.testfiles = ['tests/transcript.txt']