Loading fixtures in django unit tests Loading fixtures in django unit tests django django

Loading fixtures in django unit tests


I've specified path relative to project root in the TestCase like so:

from django.test import TestCaseclass MyTestCase(TestCase):    fixtures = ['/myapp/fixtures/dump.json',]    ...

and it worked without using FIXTURE_DIRS


Good practice is using PROJECT_ROOT variable in your settings.py:

import os.pathPROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))FIXTURE_DIRS = (os.path.join(PROJECT_ROOT, 'fixtures'),)


Do you really have a folder /fixtures/ on your hard disk?

You probably intended to use:

FIXTURE_DIRS = ('/path/to/proj_folder/fixtures/',)