test_session.py 文件源码

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

项目:dataplicity-lomond 作者: wildfoundry 项目源码 文件源码
def test_run_with_send_request_raising_exception(session, mocker):
    # exactly like the one above, but a different type of error is raised.
    # this time, we have to set the state of socket to closed, thus forcing
    # lomond to throw a non-socket error;
    def return_fake_socket(self):
        self.websocket.state.closed = True
        return FakeSocket()

    mocker.patch(
        'lomond.session.WebsocketSession._connect', return_fake_socket)

    _events = list(session.run())

    assert isinstance(_events[-1], events.ConnectFail)
    assert str(_events[-1]) == (
        "ConnectFail('request error; data not sent')"
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号