59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
# coding:utf-8
|
||
import os
|
||
import time
|
||
import pytest
|
||
import allure
|
||
import serial
|
||
import datetime
|
||
|
||
from PyEcLib.PyATLib import EcATCmdTester
|
||
|
||
ser = serial.Serial('COM13',115200,rtscts =0)
|
||
if ser.is_open == True:
|
||
ser.close()
|
||
ser.open()
|
||
ser.rts=0
|
||
ser.dtr=0
|
||
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...')
|
||
|
||
# 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--->")
|
||
|
||
AT=b'AT\r\n'
|
||
|
||
#@pytest.mark.repeat(1)
|
||
@pytest.mark.run(order=1)
|
||
@allure.feature('基本功能测试')
|
||
@allure.story('AT功能')
|
||
@allure.title("AT测试")
|
||
#severity:blocker/critical/major/normal 优先级
|
||
@allure.severity("blocker")
|
||
def test0():
|
||
print('run test0 -- test at')
|
||
print("test time:"+nowtime.strftime('%Y-%m-%d %H:%M:%S'))
|
||
EcTester.EC_UartSend(AT)
|
||
result = EcTester.EC_PollString('OK',10)
|
||
EcTester.EC_LOG("result = "+str(result[1]))
|
||
if(result[0] == True):
|
||
EcTester.EC_LOG('test AT ...................................OK')
|
||
return True
|
||
EcTester.EC_LOG('test AT ...................................Fail!')
|
||
assert 'success' == 'failed'
|
||
return False
|