@@ -16,18 +16,24 @@ class TestPythonStandardRunner(object):
1616
1717 def test_init_with_params (self ):
1818 assert self .runner .params == PythonStandardRunnerConfigParams (
19- collect_tests_options = [], include_curr_dir = False
19+ collect_tests_options = [], include_curr_dir = True
2020 )
2121 config_params = PythonStandardRunnerConfigParams (
2222 collect_tests_options = ["--option=value" , "-option" ], include_curr_dir = True
2323 )
2424 runner_with_params = PythonStandardRunner (config_params )
2525 assert runner_with_params .params == config_params
2626
27+ @patch (
28+ "codecov_cli.runners.python_standard_runner.getcwd" ,
29+ return_value = "current directory" ,
30+ )
2731 @patch ("codecov_cli.runners.python_standard_runner.path" )
2832 @patch ("codecov_cli.runners.python_standard_runner.StringIO" )
2933 @patch ("codecov_cli.runners.python_standard_runner.pytest" )
30- def test_execute_pytest (self , mock_pytest , mock_stringio , mock_sys_path ):
34+ def test_execute_pytest (
35+ self , mock_pytest , mock_stringio , mock_sys_path , mock_getcwd
36+ ):
3137 output = "Output in stdout"
3238 mock_getvalue = MagicMock (return_value = output )
3339 mock_stringio .return_value .__enter__ .return_value .getvalue = mock_getvalue
@@ -37,13 +43,20 @@ def test_execute_pytest(self, mock_pytest, mock_stringio, mock_sys_path):
3743 mock_pytest .main .assert_called_with (["--option" , "--ignore=batata" ])
3844 mock_stringio .assert_called ()
3945 mock_getvalue .assert_called ()
40- mock_sys_path .append .assert_not_called ()
46+ mock_sys_path .append .assert_called_with ("current directory" )
47+ mock_sys_path .remove .assert_called_with ("current directory" )
4148 assert result == output
4249
50+ @patch (
51+ "codecov_cli.runners.python_standard_runner.getcwd" ,
52+ return_value = "current directory" ,
53+ )
4354 @patch ("codecov_cli.runners.python_standard_runner.path" )
4455 @patch ("codecov_cli.runners.python_standard_runner.StringIO" )
4556 @patch ("codecov_cli.runners.python_standard_runner.pytest" )
46- def test_execute_pytest_fail (self , mock_pytest , mock_stringio , mock_sys_path ):
57+ def test_execute_pytest_fail (
58+ self , mock_pytest , mock_stringio , mock_sys_path , mock_getcwd
59+ ):
4760 output = "Output in stdout"
4861 mock_getvalue = MagicMock (return_value = output )
4962 mock_stringio .return_value .__enter__ .return_value .getvalue = mock_getvalue
@@ -55,13 +68,13 @@ def test_execute_pytest_fail(self, mock_pytest, mock_stringio, mock_sys_path):
5568 mock_pytest .main .assert_called_with (["--option" , "--ignore=batata" ])
5669 mock_stringio .assert_called ()
5770 mock_getvalue .assert_called ()
58- mock_sys_path .append .assert_not_called ( )
71+ mock_sys_path .append .assert_called_with ( "current directory" )
5972
6073 @patch ("codecov_cli.runners.python_standard_runner.getcwd" )
6174 @patch ("codecov_cli.runners.python_standard_runner.path" )
6275 @patch ("codecov_cli.runners.python_standard_runner.StringIO" )
6376 @patch ("codecov_cli.runners.python_standard_runner.pytest" )
64- def test_execute_pytest_include_curr_dir (
77+ def test_execute_pytest_NOT_include_curr_dir (
6578 self , mock_pytest , mock_stringio , mock_sys_path , mock_getcwd
6679 ):
6780 output = "Output in stdout"
@@ -70,14 +83,13 @@ def test_execute_pytest_include_curr_dir(
7083 mock_stringio .return_value .__enter__ .return_value .getvalue = mock_getvalue
7184 mock_pytest .main .return_value = ExitCode .OK
7285
73- config_params = PythonStandardRunnerConfigParams (include_curr_dir = True )
86+ config_params = PythonStandardRunnerConfigParams (include_curr_dir = False )
7487 runner = PythonStandardRunner (config_params )
7588 result = runner ._execute_pytest (["--option" , "--ignore=batata" ])
7689 mock_pytest .main .assert_called_with (["--option" , "--ignore=batata" ])
7790 mock_stringio .assert_called ()
7891 mock_getvalue .assert_called ()
79- mock_sys_path .append .assert_called_with ("current directory" )
80- mock_sys_path .remove .assert_called_with ("current directory" )
92+ mock_sys_path .append .assert_not_called ()
8193 mock_getcwd .assert_called ()
8294 assert result == output
8395
0 commit comments