[Answered ]-Django: repeat testcase with different fixtures

1👍

Did you consider to parameterize on class level, i.e. via class attribute?

class TestBikeBase:
    COLOR = ""  # Override in derived class.

    def setUp(self, *args, **kwargs):
        self.bike = Bike.objects.get(color=self.COLOR)

        run_expensive_commands(self.bike)

    def test_bike_1(self):
        # one of many tests

    def test_bike_2(self):
        # second of many tests


class TestRedBike(TestBikeBase, TestCase):
    COLOR = "red"


class TestBlueBike(TestBikeBase, TestCase):
    COLOR = "blue" 

Leave a comment