1

テストが機能しません。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
4

1 に答える 1

3

--fake私の知る限り、個々の移行に選択的に追加するには、カスタムテストランナーを作成する必要があります。

データベースの移行を修正する必要があります。同じテーブルを作成しようとしている2つの移行があるようです。

Southは、テストを開始する前に、初期データベースを構築するために、すべての移行を順番に実行したいと考えていますが、現在はそれを実行できません。

settings.pyこれをファイル(参照)に入れると、ユニットテストでSouthを完全に無効にできます。

SOUTH_TESTS_MIGRATE = False

これを行うと、Djangoテストランナーは、移行を実行して構築するのではなく、現在のモデルに基づいてテストデータベースを作成するだけです。

于 2013-02-13T15:32:33.310 に答える