【问题标题】:django not running tests after adding southdjango 在添加南后没有运行测试
【发布时间】:2013-08-26 22:59:21
【问题描述】:

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

这是错误:

> 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 吗?

【问题讨论】:

    标签: django django-south django-testing django-tests


    【解决方案1】:

    通过在 settings.py 中指定 SOUTH_TESTS_MIGRATE = False,让 syncdb 创建您的测试数据库。引用docs:

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

    【讨论】:

      猜你喜欢
      • 2011-06-21
      • 2014-05-31
      • 2013-02-01
      • 2013-12-09
      • 2014-01-21
      • 2011-06-03
      • 1970-01-01
      • 2014-08-03
      • 1970-01-01
      相关资源
      最近更新 更多