my_test_case.py
from unittest import TestCase, case
import time
class TestCase_(TestCase):
# 是否开启失败重跑
FAILURE_REPEAT_RUN_FLAG = True
# 失败重跑尝试次数
FAILURE_REPEAT_RUN_NUM = 5
# 设置重跑时间间隔
REPEAT_TIME_INTERVAL = 3
def run(self, result=None):
run_count = 1
orig_result = result
if result is None:
result = self.defaultTestResult()
startTestRun = getattr(result, 'startTestRun', None)
if startTestRun is not None:
startTestRun()
result.startTest(self)
testMethod = getattr(self, self._testMethodName)
if (getattr(self.__class__, "__unittest_skip__", False) or
getattr(testMethod, "__unittest_skip__", False)):