标签:class pen headers head flask amp pos blog 图片
在flask自动化测试中如何上传图片或者文件
import StringIO picture = StringIO.StringIO(open(‘/home/admin/Pictures/test.jpg‘, ‘rb‘).read()) data = dict( {‘picture‘: (picture, ‘test.jpg‘)}, timestamp=self.timestamp, check = check, ) base_url = ‘/uploadPhoto‘ rv = self.app.post(base_url, data=data, headers=HEADERS, ) print rv.data
上传文件也是一样额,把picture改为文件内容即可
标签:class pen headers head flask amp pos blog 图片
原文地址:http://www.cnblogs.com/lgh344902118/p/7825252.html