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.

classSomeTest(LiveServerTestCase):
        @classmethoddefsetUpClass(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"