Skip to content

Commit d0ba1d5

Browse files
committed
Updating unit tests
1 parent 73c8e6d commit d0ba1d5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_cmd2.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,18 @@ def test_cmdloop_without_rawinput():
847847
out = app.stdout.getvalue()
848848
assert out == expected
849849

850+
@pytest.mark.skipif(sys.platform.startswith('win'),
851+
reason="stty sane only run on Linux/Mac")
852+
def test_stty_sane(base_app, monkeypatch):
853+
"""Make sure stty sane is run on Linux/Mac after each command if stdin is a terminal"""
854+
with mock.patch('sys.stdin.isatty', mock.MagicMock(name='isatty', return_value=True)):
855+
# Mock out the subprocess.Popen call so we don't actually run stty sane
856+
m = mock.MagicMock(name='Popen')
857+
monkeypatch.setattr("subprocess.Popen", m)
858+
859+
base_app.onecmd_plus_hooks('help')
860+
m.assert_called_once_with(['stty', 'sane'])
861+
850862
class HookFailureApp(cmd2.Cmd):
851863
def __init__(self, *args, **kwargs):
852864
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)