def test_response_exception(): resp = Response() yield resp.write_body("aaa") with pytest.raises(StreamingError): yield resp.write_header("aaa") resp.flush() with pytest.raises(TChannelError): yield resp.write_body("aaaa")