def assertContains(a, b, msg, funcname=None, func=str): if type(b) not in [list, tuple]: if func(b) not in func(a): savescreen(funcname) raise Exception(msg + ":'%s' not in '%s'" % (b, a)) else: errorList = [] for i in b: if func(i) not in func(a): errorList.append("'%s' not in '%s'" % (i, a)) if errorList: savescreen(funcname) raise Exception(msg + "|".join(errorList))
def assertNotEquals(a, b, msg, funcname=None, func=str): if func(a) == func(b): if funcname: savescreen(funcname) raise Exception(msg + ":%s == %s" % (a, b))
def assertEmpty(a, msg, funcname=None): if a: if funcname: savescreen(funcname) raise Exception(msg)
from commons.base.driver import driver from config import Config, report_template from commons.base.utils import parse_report_file, savescreen from jinja2 import Template import time import pytest import os current_time = time.strftime("%Y_%m_%d_%H%M%S") with open("cur_time", "w") as f: f.write(current_time) sys.argv.extend(["--junitxml=%s.xml" % current_time]) pytest.main(args=sys.argv[1:]) savescreen("end") if Config.DEBUG: report_path = os.getcwd() + "/%s.xml" % current_time result_dict = parse_report_file(report_path, current_time) html_report = Template(report_template).render(test_result=result_dict) report_file = "file://" + os.getcwd( ) + "/reports/%s.html" % current_time with open("reports/%s.html" % current_time, "w") as f: f.write(html_report) os.system("rm -rf *.xml cur_time")