@@ -678,47 +678,45 @@ def test_edit_file(base_app, request, monkeypatch):
678678 # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
679679 base_app .editor = 'fooedit'
680680
681- # Mock out the os.system call so we don't actually open an editor
682- m = mock .MagicMock (name = 'system ' )
683- monkeypatch .setattr ("os.system " , m )
681+ # Mock out the subprocess.Popen call so we don't actually open an editor
682+ m = mock .MagicMock (name = 'Popen ' )
683+ monkeypatch .setattr ("subprocess.Popen " , m )
684684
685685 test_dir = os .path .dirname (request .module .__file__ )
686686 filename = os .path .join (test_dir , 'script.txt' )
687687
688688 run_cmd (base_app , 'edit {}' .format (filename ))
689689
690- # We think we have an editor, so should expect a system call
691- m .assert_called_once_with ('{} {}' .format (utils .quote_string_if_needed (base_app .editor ),
692- utils .quote_string_if_needed (filename )))
690+ # We think we have an editor, so should expect a Popen call
691+ m .assert_called_once ()
693692
694693def test_edit_file_with_spaces (base_app , request , monkeypatch ):
695694 # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
696695 base_app .editor = 'fooedit'
697696
698- # Mock out the os.system call so we don't actually open an editor
699- m = mock .MagicMock (name = 'system ' )
700- monkeypatch .setattr ("os.system " , m )
697+ # Mock out the subprocess.Popen call so we don't actually open an editor
698+ m = mock .MagicMock (name = 'Popen ' )
699+ monkeypatch .setattr ("subprocess.Popen " , m )
701700
702701 test_dir = os .path .dirname (request .module .__file__ )
703702 filename = os .path .join (test_dir , 'my commands.txt' )
704703
705704 run_cmd (base_app , 'edit "{}"' .format (filename ))
706705
707- # We think we have an editor, so should expect a system call
708- m .assert_called_once_with ('{} {}' .format (utils .quote_string_if_needed (base_app .editor ),
709- utils .quote_string_if_needed (filename )))
706+ # We think we have an editor, so should expect a Popen call
707+ m .assert_called_once ()
710708
711709def test_edit_blank (base_app , monkeypatch ):
712710 # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock
713711 base_app .editor = 'fooedit'
714712
715- # Mock out the os.system call so we don't actually open an editor
716- m = mock .MagicMock (name = 'system ' )
717- monkeypatch .setattr ("os.system " , m )
713+ # Mock out the subprocess.Popen call so we don't actually open an editor
714+ m = mock .MagicMock (name = 'Popen ' )
715+ monkeypatch .setattr ("subprocess.Popen " , m )
718716
719717 run_cmd (base_app , 'edit' )
720718
721- # We have an editor, so should expect a system call
719+ # We have an editor, so should expect a Popen call
722720 m .assert_called_once ()
723721
724722
0 commit comments