2

sqlite を使用してテストを実行しているときに django 1.4 にアップグレードした後、次のエラーが発生します。

Creating test database for alias 'default'...
Problem installing fixture '/home/devasia/pyserver/project/mysite/app/fixtures/test_data.json':        Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 196, in handle
obj.save(using=using)
File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/base.py", line 165, in save
  models.Model.save_base(self.object, using=using, raw=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 529, in save_base
 rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 557, in _update
 return query.get_compiler(self.db).execute_sql(None)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 986, in   execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: Could not load auth.Permission(pk=31): columns content_type_id, codename are not unique


----------------------------------------------------------------------
Ran 1 test in 0.011s

OK
Destroying test database for alias 'default'...

これは私のサンプル テスト ケースです。

class CheckTest(TestCase):
    fixtures = ['test_data.json']
    def test_check(self):
        c = Client()
        c.login(username = 'test', password = 'test')

備品は古いバージョンのものではありません。「syncdb」コマンドから始まるdjango 1.4を使用して、このフィクスチャを作成しました。テスト データベースとして postgresql を使用すると、テストは正常に実行されます (テストの実行は非常に遅くなります)。アップグレード中に何か見逃しましたか? このhttps://code.djangoproject.com/ticket/14731を見つけましたが、問題を解決できませんでした。(古いプロジェクトの唯一のコード/データはモデルであることに注意してください)

ありがとう

4

0 に答える 0