def test__prints_textual_response_with_success_msg(self):
# When the response has a status code of 2XX, and the response body is
# textual print_response_content() will print a success message to the
# TTY.
status_code = random.randrange(200, 300)
response = httplib2.Response({
'status': status_code,
'content': b"Lorem ipsum dolor sit amet.",
'content-type': 'text/unicode',
})
buf = io.BytesIO()
self.patch(buf, 'isatty').return_value = True
utils.print_response_content(response, response['content'], buf)
self.assertEqual(
b"Success.\n"
b"Machine-readable output follows:\n" +
response['content'] + b"\n", buf.getvalue())
评论列表
文章目录