2024-05-29 01:53:34 发布
网友
我用鼻子。你知道吗
我现在的代码是:
class A(): def __init__(): pass def do_somthing(self): do_it class Test(unittest.TestCase): def setUp(self): self.a = A() def testSomthing: raise assert(self.a.do_something())
我不想每次测试都创建一个类的实例,我只想创建一次。我该怎么做?你知道吗
您可以使用setUpClass,请参见the documentation:
setUpClass
A class method called before tests in an individual class run. setUpClass is called with the class as the only argument and must be decorated as a classmethod():
classmethod()
@classmethod def setUpClass(cls): ...
您可以使用
setUpClass
,请参见the documentation:相关问题 更多 >
编程相关推荐