def report(self): global path, data data = GetValue() now_time = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') path = GetPath(data.getvalue('report_path') + '%s.html' % now_time) report_path = path.get_filePath() with open(report_path, 'wb') as fp: global runner runner = HTMLTestRunner.HTMLTestRunner( stream=fp, title=data.getvalue('title'), description=data.getvalue('description')) suiteTest = unittest.TestSuite() path = GetPath(data.getvalue('cases_path')) all_cases = unittest.defaultTestLoader.discover( path.get_filePath(), 'test_*.py') for case in all_cases: suiteTest.addTest(case) runner.run(suiteTest) email = Smtp() email.sendEmail(report_path)
def setUp(self): global driver, data data = GetValue() browser = GetPath(data.getvalue('driver')) driver = webdriver.Chrome(browser.get_filePath()) user = Login(driver) user.login(data.getvalue('address'), data.getvalue('account'), data.getvalue('password'))
def __init__(self, datapath='data\\params.txt'): #win/linux路径不同,需要修改 path = GetPath(datapath) self.datapath = path.get_filePath()