1

我遇到了一个我认为是 Django South、SQLite 和测试的问题。在将 South 引入应用程序之前,我的测试一直有效。我曾经使用内存中的 SQLite,一切正常。现在有了 South 我得到一个错误,说我的一个数据库表已经存在并且它失败了。

这是错误:

> python manage.py test protocols --settings=bionetbook.settings.test
Creating test database for alias 'default'...
/Projects/project/app/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2013-08-09 00:00:00) while time zone support is active.
  RuntimeWarning)
FATAL ERROR - The following SQL query failed: CREATE TABLE "stuff_stuff" ("id" integer NOT NULL PRIMARY KEY, "created" datetime NOT NULL, "modified" datetime NOT NULL, "user_id" integer NOT NULL, "start" datetime NOT NULL, "name" varchar(255) NOT NULL, "data" text NULL, "slug" varchar(255) NULL);
The error was: table "stuff_stuff" already exists
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had 
 ! to leave it in an interim state between migrations.

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

 ! 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: stuff:0003_initial

我是否正在转动我的轮子试图让这三个人一起工作?South 不喜欢测试工具和 SQLite 吗?

4

1 回答 1

2

让我们通过在 settings.py 中syncdb指定来创建您的测试数据库。SOUTH_TESTS_MIGRATE = False引用自文档

如果这是 False,South 的测试运行器集成将使用 syncdb 创建测试数据库,而不是通过迁移(默认)。

于 2013-08-26T23:00:28.797 回答