无法引发异常作为模拟side_effect

时间:2019-12-10 05:14:00

标签: flask mocking pytest

我一直在尝试从python中的模拟引发异常,但我不断 AssertionError: Exception not raised

    @patch('__builtin__.open')
    @patch('src.pipeline_config.yaml.load', return_value={"pipeline_config_list": []})
    def test_get_pipeline_config_raises_exception(self, mock_open, mock_yaml):
        app = Flask(__name__)
        with app.app_context():
                with self.assertRaises(IOError):
                    mock_open.side_effect = IOError()
                    get_pipeline_config_list(None, "username")  

0 个答案:

没有答案
相关问题