0

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?

DoronS
  • 347
  • 1
  • 6
  • 12

1 Answers1

1

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):
    ...
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437