标签:case expected tools tca 开始 log json imp tool
import unittest from API_AUTO.tools.http_request import HttpRequest class TestLogin(unittest.TestCase): def setUp(self): print("开始执行测试用例") def tearDown(self): print("用例执行完毕") def __init__(self, methodName, url, method, data, expected): super(TestLogin, self).__init__(methodName) self.url = url self.method = method self.data = data self.expected = expected def test_api(self): res = HttpRequest().http_request(self.url, self.method, self.data) r = res.json()["info"] try: self.assertEqual(r, self.expected) except AssertionError as e: print("test_case‘s error is {}".format(e)) raise e # 处理异常后抛出去,才能被检测到用例失败了 if __name__ == ‘__main__‘: unittest.main()
标签:case expected tools tca 开始 log json imp tool
原文地址:https://www.cnblogs.com/come202011/p/12229723.html