summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-02-26 22:33:22 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-02-26 22:33:22 -0500
commiteecd1c54a3e731cc38900eab7bca62444eb67279 (patch)
tree83752ce309825f0ce33b794aa9a219fb379bbc65 /tests/test_cmd2.py
parenta3511a69bde151ac8273d71f1b6b720217576f42 (diff)
parent7b1b8b10e35b57a813369c9b23876d3615213026 (diff)
downloadcmd2-git-eecd1c54a3e731cc38900eab7bca62444eb67279.tar.gz
Merged master into history branch and fixed merge conflicts
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 51b51224..8d0d56c6 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -678,47 +678,45 @@ def test_edit_file(base_app, request, monkeypatch):
# Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
base_app.editor = 'fooedit'
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
+ # Mock out the subprocess.Popen call so we don't actually open an editor
+ m = mock.MagicMock(name='Popen')
+ monkeypatch.setattr("subprocess.Popen", m)
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'script.txt')
run_cmd(base_app, 'edit {}'.format(filename))
- # We think we have an editor, so should expect a system call
- m.assert_called_once_with('{} {}'.format(utils.quote_string_if_needed(base_app.editor),
- utils.quote_string_if_needed(filename)))
+ # We think we have an editor, so should expect a Popen call
+ m.assert_called_once()
def test_edit_file_with_spaces(base_app, request, monkeypatch):
# Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
base_app.editor = 'fooedit'
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
+ # Mock out the subprocess.Popen call so we don't actually open an editor
+ m = mock.MagicMock(name='Popen')
+ monkeypatch.setattr("subprocess.Popen", m)
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'my commands.txt')
run_cmd(base_app, 'edit "{}"'.format(filename))
- # We think we have an editor, so should expect a system call
- m.assert_called_once_with('{} {}'.format(utils.quote_string_if_needed(base_app.editor),
- utils.quote_string_if_needed(filename)))
+ # We think we have an editor, so should expect a Popen call
+ m.assert_called_once()
def test_edit_blank(base_app, monkeypatch):
# Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
base_app.editor = 'fooedit'
- # Mock out the os.system call so we don't actually open an editor
- m = mock.MagicMock(name='system')
- monkeypatch.setattr("os.system", m)
+ # Mock out the subprocess.Popen call so we don't actually open an editor
+ m = mock.MagicMock(name='Popen')
+ monkeypatch.setattr("subprocess.Popen", m)
run_cmd(base_app, 'edit')
- # We have an editor, so should expect a system call
+ # We have an editor, so should expect a Popen call
m.assert_called_once()