diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-17 02:00:52 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-17 02:00:52 -0500 |
commit | d0ba1d56858ac280050e57a02913dbd8540095b9 (patch) | |
tree | 4c1bfde45e354326d690f70b9aae2644bf62304b /tests | |
parent | 73c8e6ddababff15ca931548340558f5b20db55e (diff) | |
download | cmd2-git-d0ba1d56858ac280050e57a02913dbd8540095b9.tar.gz |
Updating unit tests
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_cmd2.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 5433a79d..f9c3e61d 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -847,6 +847,18 @@ def test_cmdloop_without_rawinput(): out = app.stdout.getvalue() assert out == expected +@pytest.mark.skipif(sys.platform.startswith('win'), + reason="stty sane only run on Linux/Mac") +def test_stty_sane(base_app, monkeypatch): + """Make sure stty sane is run on Linux/Mac after each command if stdin is a terminal""" + with mock.patch('sys.stdin.isatty', mock.MagicMock(name='isatty', return_value=True)): + # Mock out the subprocess.Popen call so we don't actually run stty sane + m = mock.MagicMock(name='Popen') + monkeypatch.setattr("subprocess.Popen", m) + + base_app.onecmd_plus_hooks('help') + m.assert_called_once_with(['stty', 'sane']) + class HookFailureApp(cmd2.Cmd): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) |