[Django]-Why is Django-1.3 not finding my fixtures for a UnitTest?

3👍

Import the TestCase from django.test;

  • Not: import unittest
  • Not: import django.utils.unittest
  • But: import django.test

Like this:

from django.test import TestCase

class test_something(TestCase):
    fixtures = ['one.json', 'two.json']
    ...

https://docs.djangoproject.com/en/1.3/topics/testing/#django.test.TestCase

0👍

You don’t pass the full path to the fixture, just the fixture name:

fixtures = ['fixture_questions.json']  

As long as the fixture is in a fixtures directory within an app that’s in INSTALLED_APPS, Django will find it.

Leave a comment