diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 16:57:59 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 16:57:59 -0500 |
commit | 0b6cf473f2613aad057e0c451b954479c0f9bc78 (patch) | |
tree | 3ff794a51cfcf04a9991ffac2dfb93b47f898f4b /tests/test_transcript.py | |
parent | de8a706e0acf8e2acbba2732540aedf66a677a4e (diff) | |
download | cmd2-git-0b6cf473f2613aad057e0c451b954479c0f9bc78.tar.gz |
Added a couple more unit tests.
One for transcript testing with multi-line commands and commments at the beginning.
Another for cmdloop testing with use_rawinput = False
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r-- | tests/test_transcript.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 36e537bc..1aab653c 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -283,3 +283,29 @@ def test_transcript_from_cmdloop(request, capsys): else: assert err == '' assert out == '' + + +def test_multiline_command_transcript_with_comments_at_beginning(request, capsys): + # Create a cmd2.Cmd() instance and make sure basic settings are like we want for test + app = CmdLineApp() + + # Get location of the transcript + test_dir = os.path.dirname(request.module.__file__) + transcript_file = os.path.join(test_dir, 'multiline_transcript.txt') + + # Need to patch sys.argv so cmd2 doesn't think it was called with arguments equal to the py.test args + testargs = ['prog', '-t', transcript_file] + with mock.patch.object(sys, 'argv', testargs): + # Run the command loop + app.cmdloop() + + # Check for the unittest "OK" condition for the 1 test which ran + expected_start = ".\n----------------------------------------------------------------------\nRan 1 test in" + expected_end = "s\n\nOK\n\n" + out, err = capsys.readouterr() + if six.PY3: + assert err.startswith(expected_start) + assert err.endswith(expected_end) + else: + assert err == '' + assert out == '' |