编程语言
首页 > 编程语言> > python – Django Unittest不加载灯具

python – Django Unittest不加载灯具

作者:互联网

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

(Python 2.7.1,Django 1.3.1)

我的app(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)

general.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.

解决方法:

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

标签:python,unit-testing,django,django-unittest
来源: https://codeday.me/bug/20190714/1455922.html