@@ -459,15 +459,15 @@ def test_history_edit(base_app, monkeypatch):
459459 # going to call it due to the mock
460460 base_app .editor = 'fooedit'
461461
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 )
465465
466466 # Run help command just so we have a command in history
467467 run_cmd (base_app , 'help' )
468468 run_cmd (base_app , 'history -e 1' )
469469
470- # We have an editor, so should expect a system call
470+ # We have an editor, so should expect a Popen call
471471 m .assert_called_once ()
472472
473473def test_history_run_all_commands (base_app ):
@@ -883,46 +883,44 @@ def test_edit_file(base_app, request, monkeypatch):
883883 base_app .editor = 'fooedit'
884884
885885 # 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 )
888888
889889 test_dir = os .path .dirname (request .module .__file__ )
890890 filename = os .path .join (test_dir , 'script.txt' )
891891
892892 run_cmd (base_app , 'edit {}' .format (filename ))
893893
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 ()
897896
898897def test_edit_file_with_spaces (base_app , request , monkeypatch ):
899898 # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
900899 base_app .editor = 'fooedit'
901900
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 )
905904
906905 test_dir = os .path .dirname (request .module .__file__ )
907906 filename = os .path .join (test_dir , 'my commands.txt' )
908907
909908 run_cmd (base_app , 'edit "{}"' .format (filename ))
910909
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 ()
914912
915913def test_edit_blank (base_app , monkeypatch ):
916914 # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
917915 base_app .editor = 'fooedit'
918916
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 )
922920
923921 run_cmd (base_app , 'edit' )
924922
925- # We have an editor, so should expect a system call
923+ # We have an editor, so should expect a Popen call
926924 m .assert_called_once ()
927925
928926
0 commit comments