diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-12 11:58:53 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-12 11:58:53 -0400 |
commit | bc24624c93d80e64fba9d59455b7bc5a24eb4a1a (patch) | |
tree | 9bcff86b2b357ca9d7704e1ab453764705d80074 /tests/test_transcript.py | |
parent | c0f92d1c3d3a00aa82f0ded091fde1e3a16022e8 (diff) | |
download | cmd2-git-bc24624c93d80e64fba9d59455b7bc5a24eb4a1a.tar.gz |
Fixed unit tests
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r-- | tests/test_transcript.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 214ef87b..4142e386 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -87,10 +87,11 @@ def test_commands_at_invocation(): expected = "This is an intro banner ...\nhello\nGracie\n" with mock.patch.object(sys, 'argv', testargs): app = CmdLineApp() - app.stdout = StdSim(app.stdout) - app.cmdloop() - out = app.stdout.getvalue() - assert out == expected + + app.stdout = StdSim(app.stdout) + app.cmdloop() + out = app.stdout.getvalue() + assert out == expected @pytest.mark.parametrize('filename,feedback_to_output', [ ('bol_eol.txt', False), @@ -121,11 +122,12 @@ def test_transcript(request, capsys, filename, feedback_to_output): # Create a cmd2.Cmd() instance and make sure basic settings are # like we want for test app = CmdLineApp() - app.feedback_to_output = feedback_to_output - # Run the command loop - sys_exit_code = app.cmdloop() - assert sys_exit_code == 0 + app.feedback_to_output = feedback_to_output + + # Run the command loop + sys_exit_code = app.cmdloop() + assert sys_exit_code == 0 # Check for the unittest "OK" condition for the 1 test which ran expected_start = ".\n----------------------------------------------------------------------\nRan 1 test in" @@ -280,11 +282,12 @@ def test_transcript_failure(request, capsys): # Create a cmd2.Cmd() instance and make sure basic settings are # like we want for test app = CmdLineApp() - app.feedback_to_output = False - # Run the command loop - sys_exit_code = app.cmdloop() - assert sys_exit_code != 0 + app.feedback_to_output = False + + # Run the command loop + sys_exit_code = app.cmdloop() + assert sys_exit_code != 0 expected_start = "File " expected_end = "s\n\nFAILED (failures=1)\n\n" @@ -298,14 +301,13 @@ def test_transcript_no_file(request, capsys): # arguments equal to the py.test args testargs = ['prog', '-t'] with mock.patch.object(sys, 'argv', testargs): - # Create a cmd2.Cmd() instance and make sure basic settings are - # like we want for test app = CmdLineApp() - app.feedback_to_output = False - # Run the command loop - sys_exit_code = app.cmdloop() - assert sys_exit_code != 0 + app.feedback_to_output = False + + # Run the command loop + sys_exit_code = app.cmdloop() + assert sys_exit_code != 0 # Check for the unittest "OK" condition for the 1 test which ran expected = 'No test files found - nothing to test\n' |