mardi 31 mars 2015

How to have a fixture loaded for Django tests in the test runner?

I have a large set of Django test cases, all of which subclass either TestCase or TransactionTestCase. I need to add a fixture to all test cases (to handle a new way of handling settings in the database).


I could of course add the fixture to the fixtures attribute of every test case. Or I could change the test cases to subclass from a custom test case subclass that sets this fixture -- and then change all existing test case fixture settings to extend rather than override the parent class fixture settings.


Either of the above would be tedious and error prone in this particular case.


So -- is there any way to get the test runner to always add a fixture to each test case as it's run?


Aucun commentaire:

Enregistrer un commentaire