@@ -459,15 +459,15 @@ def test_history_edit(base_app, monkeypatch):
459
459
# going to call it due to the mock
460
460
base_app .editor = 'fooedit'
461
461
462
- # Mock out the os.system call so we don't actually open an editor
463
- m = mock .MagicMock (name = 'system ' )
464
- monkeypatch .setattr ("os.system " , m )
462
+ # Mock out the subprocess.Popen call so we don't actually open an editor
463
+ m = mock .MagicMock (name = 'Popen ' )
464
+ monkeypatch .setattr ("subprocess.Popen " , m )
465
465
466
466
# Run help command just so we have a command in history
467
467
run_cmd (base_app , 'help' )
468
468
run_cmd (base_app , 'history -e 1' )
469
469
470
- # We have an editor, so should expect a system call
470
+ # We have an editor, so should expect a Popen call
471
471
m .assert_called_once ()
472
472
473
473
def test_history_run_all_commands (base_app ):
@@ -883,46 +883,44 @@ def test_edit_file(base_app, request, monkeypatch):
883
883
base_app .editor = 'fooedit'
884
884
885
885
# Mock out the os.system call so we don't actually open an editor
886
- m = mock .MagicMock (name = 'system ' )
887
- monkeypatch .setattr ("os.system " , m )
886
+ m = mock .MagicMock (name = 'Popen ' )
887
+ monkeypatch .setattr ("subprocess.Popen " , m )
888
888
889
889
test_dir = os .path .dirname (request .module .__file__ )
890
890
filename = os .path .join (test_dir , 'script.txt' )
891
891
892
892
run_cmd (base_app , 'edit {}' .format (filename ))
893
893
894
- # We think we have an editor, so should expect a system call
895
- m .assert_called_once_with ('{} {}' .format (utils .quote_string_if_needed (base_app .editor ),
896
- utils .quote_string_if_needed (filename )))
894
+ # We think we have an editor, so should expect a Popen call
895
+ m .assert_called_once ()
897
896
898
897
def test_edit_file_with_spaces (base_app , request , monkeypatch ):
899
898
# Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
900
899
base_app .editor = 'fooedit'
901
900
902
- # Mock out the os.system call so we don't actually open an editor
903
- m = mock .MagicMock (name = 'system ' )
904
- monkeypatch .setattr ("os.system " , m )
901
+ # Mock out the subprocess.Popen call so we don't actually open an editor
902
+ m = mock .MagicMock (name = 'Popen ' )
903
+ monkeypatch .setattr ("subprocess.Popen " , m )
905
904
906
905
test_dir = os .path .dirname (request .module .__file__ )
907
906
filename = os .path .join (test_dir , 'my commands.txt' )
908
907
909
908
run_cmd (base_app , 'edit "{}"' .format (filename ))
910
909
911
- # We think we have an editor, so should expect a system call
912
- m .assert_called_once_with ('{} {}' .format (utils .quote_string_if_needed (base_app .editor ),
913
- utils .quote_string_if_needed (filename )))
910
+ # We think we have an editor, so should expect a Popen call
911
+ m .assert_called_once ()
914
912
915
913
def test_edit_blank (base_app , monkeypatch ):
916
914
# Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
917
915
base_app .editor = 'fooedit'
918
916
919
- # Mock out the os.system call so we don't actually open an editor
920
- m = mock .MagicMock (name = 'system ' )
921
- monkeypatch .setattr ("os.system " , m )
917
+ # Mock out the subprocess.Popen call so we don't actually open an editor
918
+ m = mock .MagicMock (name = 'Popen ' )
919
+ monkeypatch .setattr ("subprocess.Popen " , m )
922
920
923
921
run_cmd (base_app , 'edit' )
924
922
925
- # We have an editor, so should expect a system call
923
+ # We have an editor, so should expect a Popen call
926
924
m .assert_called_once ()
927
925
928
926
0 commit comments