我尝试使用twisted.trial._dist.disttrial.DistTrialRunner作为运行程序,在某些情况下失败后,我想重新运行失败案例,但它没有重新启动并获得一个错误:
from twisted.trial._dist.disttrial import DistTrialRunner as Runner
runnerArgs = ({'workerNumber': 3, 'workerArguments': []})
for _ in range(3):
RetCode, FailCases = Runner(**runnerArgs).run(suite)
if RetCode == 0:
exit(RetCode)
else:
suite = FailCases
exit(RetCode)发布于 2022-07-20 13:21:37
使用runAsync而不是run
from twisted.trial._dist.disttrial import DistTrialRunner as Runner
runnerArgs = ({'workerNumber': 3, 'workerArguments': []})
async def runThreeTimes():
runner = Runner(**runnerArgs)
for _ in range(3):
result = await runner.runAsync(suite)
if result.wasSuccessful():
exit(0)
else:
suite = compute_failures_from_result(result)
exit(1)
# Run runThreeTimes, perhaps using Deferred.fromCoroutine
# Run the reactor, perhaps just by importing it and calling run() on it这仍然需要compute_failures_from_result的实现,我已经忽略了这一点,因为使用TestResult接口显然是不可能的。但是,如果您向reporterFactory提供了一个备用的DistTrialRunner,那么您就可以实现一个更好地公开成功和失败并从中提取信息的方法。
https://stackoverflow.com/questions/69099746
复制相似问题