Question

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?

Was it helpful?

Solution

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):
    ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top