3

Django testrunner is not loading fixtures out of media app fixtures/ directory. How can I debug it - find if it's looking for my fixtures and where?

(Python 2.7.1, Django 1.3.1)

My app (app_label=media) directory structure:

media/fixtures/
media/fixtures/media.json
media/fixtures/auth.json
media/tests/
media/tests/__init__
media/tests/general.py (v---- test below)

general.py

from django.utils import unittest
from apps.webmachinist.media.models import *

class GalleryItemFormTest(unittest.TestCase):

    fixtures = ['media.json','auth.json']
[...]

Traceback:

./manage.py test media --verbosity=2
Creating test database for alias 'default' (':memory:')...
Syncing...
Creating tables ...
Creating table auth_permission
[...]
Creating table tagging_taggeditem
Installing custom SQL ...
Installing indexes ...
Migrating...
Running migrations for media:
 - Migrating forwards to 0002_auto__del_field_image_image__add_field_image_file__del_field_video_vid.
 > media:0001_initial
 > media:0002_auto__del_field_image_image__add_field_image_file__del_field_video_vid
 - Loading initial data for media.
No fixtures found.
Running migrations for portfolio:
 - Migrating forwards to 0001_initial.
 > portfolio:0001_initial
 - Loading initial data for portfolio.
No fixtures found.

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.staticfiles
 > django.contrib.admin
 > django.contrib.admindocs
 > south
 > sorl.thumbnail
 > tagging

Migrated:
 - apps.webmachinist.media
 - apps.webmachinist.portfolio
No fixtures found.
Memke
  • 684
  • 1
  • 7
  • 24
  • Where are your fixture files located? Django only searches 'fixtures' directories in each app. Can you summarize your app directory structure and show where the fixture files are? – S.Lott Feb 01 '12 at 12:09
  • 1
    Please **update** the question with the additional details. Please do not add comments to a question which you own. You own it. You can make it complete, correct and consistent. Please **update** the question and then delete the hard-to-read comment. – S.Lott Feb 01 '12 at 12:30

2 Answers2

11

Use django.test.TestCase instead of unittest.TestCase.

Raekkeri
  • 761
  • 6
  • 6
3

This might save someone an extra search or two...

from django.test import TestCase

class MyTestCase(TestCase):
    fixtures = ['myfixture.json']
scoopseven
  • 1,767
  • 3
  • 18
  • 27