我刚刚开始使用单元测试,我想为每个测试运行一些代码(这就是默认的setUp()看起来如何工作),但是我想让一些代码在运行开始时只运行一次?
您应该定义一个setUpClass
方法 。
You can use setUpClass
which runs once to set up the test class. It runs before the test methods in that class are executed:
@classmethod
def setUpClass(cls):
pass
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.