2013-02-13 43 views
1

我的测试无法正常工作。如果我尝试蟒蛇manage.py测试应用程序的名字我有这样的错误:如何使用migrate appname运行测试 - 结果?

! You *might* be able to recover with: = DROP TABLE "appname_userprofile"; [] 
    = DROP TABLE "appname_table2"; [] 
    = DROP TABLE "appname_table3"; [] 

! The South developers regret this has happened, and would 
! like to gently persuade you to consider a slightly 
! easier-to-deal-with DBMS (one that supports DDL transactions) 
! NOTE: The error which caused the migration to fail is further up. 
Error in migration: content:0015_initial 
django.db.utils.DatabaseError: table "appname_userprofile" already exists 

如何运行我python manage.py test appname

manage.py migrate appname --fake 

回答

3

你必须编写自定义的测试运行,以选择性添加--fake个人据我所知,迁移。

你应该修正你的数据库迁移 - 看起来你有两个试图创建同一个表的迁移。

南希望运行所有的迁移,以便在开始测试之前,为了建立一个初始数据库,现在它不能这样做。

您可以禁用南完全单元测试,如果你把这个在您的settings.py文件(reference):

SOUTH_TESTS_MIGRATE = False 

如果你这样做,那么Django的测试运行将只根据创建测试数据库中的目前的模型,而不是运行迁移来构建它。

相关问题