Clarification of the 'Fixture loading' section of the unit test documentation
|Reported by:||igloo||Owned by:||nobody|
|Severity:||Keywords:||fixtures, testing framework, unit tests, initial_data|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The documentation could do with elaborating on the loading of fixtures by the testing framework.
Quoth the docs:
"Once you've created a fixture and placed it in a fixtures directory in one of your INSTALLED_APPS, you can use it in your unit tests by specifying a fixtures class attribute on your django.test.TestCase subclass:"
class AnimalTestCase(TestCase): fixtures = ['mammals.json', 'birds']
What that says to me is, I can put any old file in the 'fixtures' directory and load it up in the test case by referring to it by filename, eg., 'mammals.json' - however, with the default behaviour, this isn't the case. The fixtures have to be in a file called 'initial_data'. I spent about 10 minutes tearing my hair out over this one! I know it does mention this in the box directly above the bit I've quoted, but is there any chance we can make it a bit clearer?