本文主要是介绍python接口测试 unitest 测试示例-02,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
# !/user/bin/env python # -*- coding:utf-8 -*- # author:snakeimport unittest import json from post import RunMainclass TestMethod(unittest.TestCase):@classmethoddef setUpClass(cls) -> None:print('类执行之前的方法')@classmethoddef tearDownClass(cls) -> None:print('类执行之后的方法')def setUp(self):print('每次执行testcase之前都要执行setup')self.run = RunMain()def tearDown(self):print('每次执行testcase之前都要执行teardown')def test_01(self):url_01 = ''data_01 = {}print('这是第一个tesecase')res = self.run.run_main(url_01, 'POST', data_01)print(res)def test_02(self):url_02 = ''data_02 = {}print('这是第二个testcase')res = self.run.run_main(url_02, 'GET', data_02)print(res)if __name__ == '__main__':unittest.main()
这篇关于python接口测试 unitest 测试示例-02的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!