Skip to content Skip to sidebar Skip to footer

Make LiveServerTestCase Not To Call SetUp() Before Each Test

I have one problem with testing django app by using LiveServerTestCase. LiveServerTestCase execute setUp() function before executing each test. But I'm using factory-boy's factorie

Solution 1:

setUp() gets called before every test.

If you want to create the objects once for the entrire test case, you can use setUpClass() instead.

E.g.

class SomeTest(LiveServerTestCase):
        @classmethod
        def setUpClass(cls):
            # create objects here
            LiveServerTestCase.setUpClass()

Don't forget to call LiveServerTestCase.setUpClass() or the live server won't function properly.


Post a Comment for "Make LiveServerTestCase Not To Call SetUp() Before Each Test"