mardi 29 septembre 2015

Python unit test, run some methods only once

I am using Django testcase for one testsuit like this:

class XXXTests(TestCase):
    def setUp(self):
        ....

    def test_something(self):
        ....

    def test_anthoerthing(self):
        ....

Now I notice that there are a lot of things repeated in test_something() and test_anotherthing() (mostly running some method and get the returned value).

Is there any way I can only run the repeated part once for the testsuit?

Aucun commentaire:

Enregistrer un commentaire