失败用例重跑机制-python装饰器
def failrun(n=3): def decorator(func): def wrapper(*args,**kw): for i in range(n): try: r= func(*args,**kw) return r except NameError as err: print('用例第一次失败原因:%s'%err) raise NameError return wrapper return decorator @failrun(n=3) def test_b(): print(a) test_b()