# coding:utf-8 import os import time import pytest import allure import serial import datetime from PyEcLib.PyATLib import EcATCmdTester from PyEpatlib.PyEpatlib import EpatController ser = serial.Serial('COM36',115200,rtscts =0) if ser.is_open == True: ser.close() ser.open() ser.rts=0 ser.dtr=0 COMDB_LOC='D:\\\\PycharmProjects\\\\pythonProject\\\\opentest\\\\image\\\\comdb.txt' fd = open("commtest_log.txt", 'w') EcTester = EcATCmdTester(ser, 3) nowtime=datetime.datetime.now() print("test time:"+nowtime.strftime('%Y-%m-%d %H:%M:%S')) EcTester.EC_Version() EcTester.EC_LogtoFile(fd,True) #EcTester.EC_LOG('...Commtest Test Start...') #epatcon=EpatController() # setup_module 在当前模块下,所有test执行之前执行。 #def setup_module(module): # print("\n--------------------setup_module--------------------") # testdown_module 在当前模块下,所有test执行之前执行。 #def teardown_module(module): # print ("\n--------------------teardown_module--------------------") # 在每个test之前,均执行。 #def setup_function(function): # print("<-------------------------------------------------setup_function------>") # 在每个test之后,均执行。 #def teardown_function(function): # print ("<-------------------------------------------------teardown_function--->") ''' @allure.step('AT指令复位') def AT_RESET(): EcTester.EC_UartSend(b'AT+ECRST\r\n') return True AT_RESET() time.sleep(10) AT=b'AT\r\n' ''' #@pytest.mark.repeat(1) @pytest.mark.run(order=1) @allure.feature('基本功能测试') @allure.story('音频播报8K mp3') @allure.title("音频播报8K mp3") #severity:blocker/critical/major/normal @allure.severity("blocker") def test0(): # print('run test0 -- test Audio') # ntime=datetime.datetime.now() # time_str=ntime.strftime('%Y-%m-%d %H-%M-%S') # print("test time:"+time_str) # epatcon.EPAT_Stop() # epatcon.EPAT_Start() # epatcon.EPAT_DB_Setting(COMDB_LOC) EcTester.EC_UartSend(b'{"name":"systest_play_mp3","param1":0,"param2":0,"param3":"C:/NetConnetOk_8000_32000_576.mp3"}\r') # result = EcTester.EC_PollString('p_systest_json->p_param3: C:/NetConnetOk_8000_32000_576.mp3',10) # EcTester.EC_LOG("result = "+str(result[1])) # if(result[0] == True): # EcTester.EC_LOG('play audio 8k mp3 ........................OK') # return True # EcTester.EC_LOG('play audio 8k mp3 .......................Fail!') # time.sleep(6) # epatcon.EPAT_Stop() # epatcon.EPAT_Save('Z:\\\\comm_test_at_'+time_str+'.zip') # time.sleep(1) # assert 'success' == 'failed' # return False def _main(): try: main() except FatalError as e: print('\n A fatal error occurred: %s' % e) err_exit(2) if __name__ == '__main__': _main()