test_runner.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:webhook2lambda2sqs 作者: jantman 项目源码 文件源码
def test_run_test_bad_method(self, capsys):
        conf = Mock()
        conf.get.return_value = {
            'ep1': {'method': 'FOO'}
        }
        args = Mock(endpoint_name='ep1')
        res1 = Mock(spec_set=Response)
        type(res1).status_code = 200
        type(res1).content = 'res1content'
        type(res1).headers = {
            'h1': 'h1val',
            'hz': 'hzval'
        }

        with patch.multiple(
            pbm,
            autospec=True,
            requests=DEFAULT,
            logger=DEFAULT,
            get_base_url=DEFAULT,
            node=DEFAULT
        ) as mocks:
            mocks['get_base_url'].return_value = 'mybase/'
            mocks['node'].return_value = 'mynode'
            mocks['requests'].get.return_value = res1
            with pytest.raises(Exception) as excinfo:
                run_test(conf, args)
        assert exc_msg(excinfo.value) == 'Unimplemented method: FOO'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号