flask test_client设置cookies

class TestCase(unittest.TestCase):
session = None
def setUp(self):
self.app = create_app()
self.app.testing = True
###########################################################
# TODO: change settings
# import tempfile
# self.app.config['DATABASE'] = tempfile.mkstemp()
###########################################################
self.client = self.app.test_client()
self.login_required() def login_required(self):
rv = self.client.post('/login', data=dict(
account=PHONE,
password=PASSWORD
))
cookies = rv.headers.getlist('Set-Cookie')
session = parse_cookie(cookies[0])['session']
self.client.set_cookie('localhost', 'session', session)
上一篇:python接口自动化测试(七)unittest 生成测试报告


下一篇:限制对比度自适应直方图均衡(Contrast Limited Adaptive histgram equalization/CLAHE)