1- from subprocess import CalledProcessError , CompletedProcess
21from pathlib import Path
2+ from subprocess import CalledProcessError , CompletedProcess
33from unittest .mock import MagicMock , patch
44
5+ from odev .common import bash
56from odev .common .python import PythonEnv
6- from odev .common import odev , bash
77
88from tests .fixtures import OdevTestCase
99
@@ -18,17 +18,17 @@ def setUpClass(cls):
1818
1919 def test_run_script_streaming_success (self ):
2020 """Test run_script with a streaming process that succeeds."""
21- env = PythonEnv (path = "/tmp/fake_venv" , version = "3.10" )
22-
21+ env = PythonEnv (path = "/tmp/fake_venv" , version = "3.10" ) # noqa: S108
22+
2323 with (
24- self .patch (Path , "exists" , True ),
25- self .patch (PythonEnv , "exists" , True ),
26- self .patch (PythonEnv , "python" , Path ("/tmp/fake_venv/bin/python" )),
27- self .patch (bash , "stream" , return_value = iter (["line 1" , "line 2" ]))
24+ self .patch (Path , "exists" , return_value = True ),
25+ self .patch (PythonEnv , "exists" , return_value = True ),
26+ self .patch (PythonEnv , "python" , Path ("/tmp/fake_venv/bin/python" )), # noqa: S108
27+ self .patch (bash , "stream" , return_value = iter (["line 1" , "line 2" ])),
2828 ):
2929 progress_mock = MagicMock ()
3030 result = env .run_script ("fake_script.py" , stream = True , progress = progress_mock )
31-
31+
3232 self .assertIsInstance (result , CompletedProcess )
3333 self .assertEqual (result .returncode , 0 )
3434 self .assertEqual (progress_mock .call_count , 2 )
@@ -37,21 +37,21 @@ def test_run_script_streaming_success(self):
3737
3838 def test_run_script_streaming_failure (self ):
3939 """Test run_script with a streaming process that fails."""
40- env = PythonEnv (path = "/tmp/fake_venv" , version = "3.10" )
41-
40+ env = PythonEnv (path = "/tmp/fake_venv" , version = "3.10" ) # noqa: S108
41+
4242 def streaming_failure (command ):
4343 yield "line 1"
4444 raise CalledProcessError (1 , command )
4545
4646 with (
47- self .patch (Path , "exists" , True ),
48- self .patch (PythonEnv , "exists" , True ),
49- self .patch (PythonEnv , "python" , Path ("/tmp/fake_venv/bin/python" )),
50- self .patch (bash , "stream" , side_effect = streaming_failure )
47+ self .patch (Path , "exists" , return_value = True ),
48+ self .patch (PythonEnv , "exists" , return_value = True ),
49+ self .patch (PythonEnv , "python" , Path ("/tmp/fake_venv/bin/python" )), # noqa: S108
50+ self .patch (bash , "stream" , side_effect = streaming_failure ),
5151 ):
5252 progress_mock = MagicMock ()
5353 result = env .run_script ("fake_script.py" , stream = True , progress = progress_mock )
54-
54+
5555 self .assertIsInstance (result , CompletedProcess )
5656 self .assertEqual (result .returncode , 1 )
5757 progress_mock .assert_called_once_with ("line 1" )
0 commit comments