如何使用迁移appname运行测试--fake?

时间:2013-02-13 14:28:23

标签: python django django-south

我的测试不起作用。如果我尝试python manage.py test 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

1 个答案:

答案 0 :(得分:3)

据我所知,你必须编写一个自定义测试运行器来有选择地将--fake添加到单个迁移中。

您应该修复数据库迁移 - 看起来您有两次尝试创建同一个表的迁移。

South希望在开始测试之前按顺序运行所有迁移,以便构建初始数据库,而现在它无法执行此操作。

如果您将其放在settings.py文件(reference)中,则可以完全禁用南单元测试:

SOUTH_TESTS_MIGRATE = False

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

相关问题