【python】接口自动化初识第三站

import unittest
import requests

# class TestDemo(unittest.TestCase):
# def setUp(self) -> None:
# self.session=requests.session()
# def tearDown(self) -> None:
# self.session.close()
#
# def test_get_accesstoken_api(self):
# get_param_dict={'grant_type':'client_credential',
# 'appid':'wx55614004f367f8ca',
# 'secret':'65515b46dd758dfdb09420bb7db2c67f'}
# # 一般不是这种写法
# # response=requests.get(url='https://api.weixin.qq.com/cgi-bin/token',
# #一般是这种
# response = self.session.get(url='https://api.weixin.qq.com/cgi-bin/token',
# params=get_param_dict)
# actual_res = response.status_code
# self.assertEqual(actual_res,200)
# if __name__=='__main__':
# unittest.main()

原文地址:https://www.cnblogs.com/luoguoxing/p/14037761.html