[英]django 1.7: Problems loading the initial fixture of the test
环境:
Django版本:1.7.1
鼻子版本:1.3.4
django-nose版本:1.2
我有两个应用程序:
狗与人
该模型具有:
class Dog(models.Model):
human = models.ForeignKey('humans.Human', null=False)
def askFood(human):
...
人的
在模型中有一个函数,例如人类的示例属性,例如
name = models.CharField(_('Name'), null=False, max_length=120)
这两个应用在设置文件中的INSTALLED_APPS中列出。
FIXURE_DIRS如下:
FIXTURE_DIRS = (
os.path.join(os.path.dirname(__file__), '../**/tests'),
)
测试位于dog应用程序的tests文件夹中。
我在dog应用程序中进行了测试以测试askFood函数,并且我使用了人类的JSON夹具(initial_data)。
[
{
"pk": 1,
"model": "human.Human",
"fields": {
"name": "Test"
}
},
]
测试是:
class DogFixtureTestCase(TestCase):
fixtures = ['./initial_data.json']
class TestFixtureDog(DogFixtureTestCase):
def test_ask_food(self):
...
我执行命令进行测试:
python manage.py test dog
发生错误:
no such table: dog_dog
显然,它并没有同步所有的应用程序,而是仅创建了狗的表,当灯具运行时,它找不到人的表。 如何强制测试为所有应用创建模型?
先谢谢您的帮助 :)
[编辑]
我更改了标题并发布了答案,也许可以帮助遇到相同问题的人。
问题不在于同步不会创建所有表,而是误导性的错误消息。 问题出在django 1.7不再支持的初始数据夹具上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.