zs2*_*020 8 python unit-testing
我正在使用python单元测试模块.我想知道无论如何在每2个测试用例之间增加一些延迟?因为我的单元测试只是发出http请求,我猜服务器可能会阻止来自同一个ip的频繁请求.
Dan*_*olo 14
把睡眠放在tearDown
你的方法里面TestCase
import time
class ExampleTestCase(unittest.TestCase):
def tearDown(self):
time.sleep(1) # sleep time in seconds
Run Code Online (Sandbox Code Playgroud)
tearDown()
将在该TestCase
课程中的每次测试后执行.
模块文档可以在这里找到.