문제

I'm using nose.

My current code is:

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())

I don't want to create an instance of A class each test, I want to create it only once. How can i do that?

도움이 되었습니까?

해결책

You could use setUpClass, see the documentation:

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
def setUpClass(cls):
    ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top