'Is there a way to introduce a small delay between each unittest case?
i'm testing an application inside a docker container, and it seems that the application crashes for some virtualization reason (i'm forced to use an qemu emulated amd64 container on an M1 Mac).
I've read that the qemu layer stability is I/O sensible. Is there a way to slow dow the unittest runner, possibly with a delay/sleep time between each test ?
Thx in advance
Solution 1:[1]
If you don't want to insert some sleep time in the setUp or tearDown methods, you can subclass and override the default TestResult by doing something like this:
import time
import unittest
class SlowTestResult(unittest.TestResult):
def startTest(self, test):
time.sleep(1)
super().startTest(test)
slowTestRunner = unittest.TextTestRunner(resultclass=SlowTestResult)
if __name__ == '__main__':
unittest.main(testRunner=slowTestRunner)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
