summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-08 14:13:13 -0400
committerGitHub <noreply@github.com>2017-07-08 14:13:13 -0400
commit88fe14caacfd5cfe590692b3e14b5af611458032 (patch)
tree45a5f052b45286d2e14b7074843c4e9124f49b6c /tests/test_cmd2.py
parenta140ad1cdb531d2bc60237502cf8601f46d60692 (diff)
parenta425e19c6a93dc7e6b0a5f13f335de9f6a5e348e (diff)
downloadcmd2-git-88fe14caacfd5cfe590692b3e14b5af611458032.tar.gz
Merge pull request #179 from python-cmd2/unit_tests
Added a few more unit tests
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 7e393b7b..8d91c8ef 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1282,3 +1282,39 @@ def test_echo(capsys):
assert app.cmdqueue == []
assert app._current_script_dir is None
assert out.startswith('help history\n' + 'history [arg]: lists past commands issued')
+
+
+def test_raw_input(base_app):
+ base_app.use_raw_input = True
+ fake_input = 'quit'
+
+ # Mock out the input call so we don't actually wait for a user's response on stdin
+ m = mock.Mock(name='input', return_value=fake_input)
+ sm.input = m
+
+ line = base_app.pseudo_raw_input('(cmd2)')
+ assert line == fake_input
+
+def test_stdin_input():
+ app = cmd2.Cmd()
+ app.use_rawinput = False
+ fake_input = 'quit'
+
+ # Mock out the readline call so we don't actually read from stdin
+ m = mock.Mock(name='readline', return_value=fake_input)
+ app.stdin.readline = m
+
+ line = app.pseudo_raw_input('(cmd2)')
+ assert line == fake_input
+
+def test_empty_stdin_input():
+ app = cmd2.Cmd()
+ app.use_rawinput = False
+ fake_input = ''
+
+ # Mock out the readline call so we don't actually read from stdin
+ m = mock.Mock(name='readline', return_value=fake_input)
+ app.stdin.readline = m
+
+ line = app.pseudo_raw_input('(cmd2)')
+ assert line == 'EOF'