3

Django testrunner 没有从媒体应用程序的fixtures/目录中加载fixtures。我该如何调试它 - 找出它是否正在寻找我的灯具以及在哪里?

(Python 2.7.1,Django 1.3.1)

我的应用(app_label=media)目录结构:

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

通用.py

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

class GalleryItemFormTest(unittest.TestCase):

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

追溯:

./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.
4

2 回答 2

11

使用django.test.TestCase而不是unittest.TestCase.

于 2012-02-01T12:52:43.013 回答
3

这可能会为某人节省一两次额外的搜索...

from django.test import TestCase

class MyTestCase(TestCase):
    fixtures = ['myfixture.json']
于 2012-07-17T20:38:51.763 回答