1# -*- coding: utf-8 -*- 2import os 3 4from APL_compare_03.compare import apl_check_main 5from devicetest.api import Asserts 6 7from test_case import ITestCase 8 9 10class APLCheck(ITestCase): 11 12 def __init__(self, controllers): 13 super().__init__(controllers) 14 self.apl_path = os.path.join(os.path.dirname(self.testcases_path), 'APL_compare_03', 'apl_compare.log') 15 16 def setup(self): 17 self.step('前置条件1:APL check 开始') 18 19 def process(self): 20 self.step('clear apl_compare.log first') 21 # 先删除文件内容 22 if os.path.exists(self.apl_path): 23 self.step('{} exist, delete before test'.format(self.apl_path)) 24 with open(self.apl_path, 'w') as f: 25 f.write('') 26 self.step('步骤2:call APL_compare_03.compare.py ...') 27 apl_check_main(self.device_name) 28 self.step('步骤3:{} exist?:{}'.format(self.apl_path, os.path.exists(self.apl_path))) 29 with open(self.apl_path, mode='r', encoding='utf-8', errors='ignore') as f: 30 f.seek(0) 31 apl_result = f.read() 32 self.asserts.assert_not_in('APL Check failed', apl_result) 33 34 def teardown(self): 35 self.step('收尾:APL check finish') 36