diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 12:11:16 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 12:11:16 -0500 |
commit | d5a0487b0058cdf52b295e9ae203e8e90f3247dd (patch) | |
tree | ba6a4ea00d300a8ca076c9da3c897bc48c2f9275 /tests | |
parent | ce71e89c1d01e03df7abba3396d9445657ad04d9 (diff) | |
download | cmd2-git-d5a0487b0058cdf52b295e9ae203e8e90f3247dd.tar.gz |
Added unit test for the interactive form of do_py().
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 11 | ||||
-rw-r--r-- | tests/test_transcript.py | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 0806bee3..d1906fc4 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -12,6 +12,8 @@ import mock import pytest import six +from code import InteractiveConsole + import cmd2 from conftest import run_cmd, normalize, BASE_HELP, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG @@ -450,3 +452,12 @@ def test_edit_blank(base_app): os.remove(base_app.default_file_name) +def test_base_py_interactive(base_app): + # Mock out the InteractiveConsole.interact() call so we don't actually wait for a user's response on stdin + m = mock.MagicMock(name='interact') + InteractiveConsole.interact = m + + run_cmd(base_app, "py") + + # Make sure our mock was called once and only once + m.assert_called_once() diff --git a/tests/test_transcript.py b/tests/test_transcript.py index d11eb02a..c3a32eac 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -236,7 +236,7 @@ def test_commands_at_invocation(_cmdline_app): def test_select_options(_demo_app): - # Mock out the input call so we don't actually wait for a user's `response on stdin + # Mock out the input call so we don't actually wait for a user's response on stdin m = mock.MagicMock(name='input', return_value='2') sm.input = m |