I have written a test to check the integrity of the data I keep in my fixtures. It is a class inheriting from django.tests.TestCase
, and it declares the fixtures it needs. When I run the methods in this class only, they pass. However, when I run all of my tests, some fixtures from other tests remain in the db, which makes the tests fail. I tried different variants, and for now I am overriding the _fixture_setup
method to kill all db data before my test, but this can't be right. There must be a better way :)
class FixturesTest(TestCase):
fixtures = ["tariff.json"]
def _fixture_setup(self):
TariffModel.objects.all().delete()
super()._fixture_setup()
def test_tariff_fixtures(self):
"""Check the fixtures for tariffs"""
...
Thanks.
Aucun commentaire:
Enregistrer un commentaire