seldom icon indicating copy to clipboard operation
seldom copied to clipboard

【需求】添加获取response返回的header信息

Open 792817377 opened this issue 2 years ago • 1 comments

目前看只有获取response,self.response 希望可以添加获取响应请求头信息

792817377 avatar Sep 14 '22 09:09 792817377

@792817377 seldom 2.9.0 版本支持返回对象。

import seldom


class TestRequest(seldom.TestCase):

    def test_get(self):
        """ test getrequest   """
        resp = self.get('http://httpbin.org/get', data={'key': 'value'})
        print(resp.headers)


if __name__ == '__main__':
    seldom.main(debug=True)

resp.headers 打印结果:


{'Server': 'nginx/1.20.1', 'Date': 'Mon, 17 Oct 2022 15:45:36 GMT', 'Content-Type': 'text/html', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Last-Modified': 'Wed, 12 Oct 2022 02:59:42 GMT', 'Cache-Control': 'public, max-age=0, must-revalidate', 'Content-Encoding': 'gzip'}

defnngj avatar Oct 17 '22 15:10 defnngj