1.导包
import unittest
2.编写测试类
def base(did=None, app_id=None, request_id=None, query=None,date=None, device=None,version=None):
body = ""
if did:
if did and app_id and not request_id and not query and not device and not version:
body += "device_id=" + did + "&" + "app_id=" + app_id
if did and request_id and not app_id and not query and not device and not version:
body += "device_id=" + did + "&" + "request_id=" + request_id
class test(unittest.TestCase):
def test_asr_info_1(self):
device_id = "11111"
r = base(did=device_id)
self.assertEqual(r["code"], 0)
self.assertEqual(len(r["data"]), 10)
for i in r["data"]:
self.assertEqual(i["deviceId"], device_id)
3.实例
if __name__ == '__main__':
unittest.main()