我正在使用unittest2
和manage.py test
,在它甚至似乎运行任何测试之前,它会发出可怕的数据库错误,如下所示。我在我的开发环境中(实际上是出于各种原因在dreamhost服务器上),使用sqlite作为我的数据库。
即使我将我的应用程序复制到用于生产的位置(并相应地编辑settings.py),我仍然会得到相同的错误(即使它不再是与开发环境相同的数据库文件)。
更新:即使将我的数据库文件的所有实例移动到不同的文件名仍然会给我留下相同的错误。这让我相信测试环境会以某种方式查看虚假数据库,或者发生一些非常奇怪的事情。
[graffias]$ python manage.py test
Creating test database for alias 'default'...
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/test.py", line 8, in handle
super(Command, self).handle(*args, **kwargs)
File "/home/marcintustin/django/Django-1.3/django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
File "/home/marcintustin/django/Django-1.3/django/test/simple.py", line 359, in run_tests
old_config = self.setup_databases()
File "/home/marcintustin/django/Django-1.3/django/test/simple.py", line 296, in setup_databases
test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
File "/home/marcintustin/django/Django-1.3/django/db/backends/creation.py", line 366, in create_test_db
load_initial_data=False)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/syncdb.py", line 99, in handle_noargs
management.call_command('migrate', **options)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/migrators.py", line 298, in migrate_many
interactive=self.interactive)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/db/generic.py", line 808, in send_pending_create_signals
interactive=interactive)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/db/generic.py", line 855, in really_send_create_signal
db=self.db_alias,
File "/home/marcintustin/django/Django-1.3/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/marcintustin/django/Django-1.3/django/contrib/auth/management/__init__.py", line 30, in create_permissions
ctype = ContentType.objects.get_for_model(klass)
File "/home/marcintustin/django/Django-1.3/django/contrib/contenttypes/models.py", line 38, in get_for_model
defaults = {'name': smart_unicode(opts.verbose_name_raw)},
File "/home/marcintustin/django/Django-1.3/django/db/models/manager.py", line 135, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "/home/marcintustin/django/Django-1.3/django/db/models/query.py", line 385, in get_or_create
obj.save(force_insert=True, using=self.db)
File "/home/marcintustin/django/Django-1.3/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/marcintustin/django/Django-1.3/django/db/models/base.py", line 560, in save_base
transaction.commit_unless_managed(using=using)
File "/home/marcintustin/django/Django-1.3/django/db/transaction.py", line 124, in commit_unless_managed
connection.commit_unless_managed()
File "/home/marcintustin/django/Django-1.3/django/db/backends/__init__.py", line 183, in commit_unless_managed
self._commit()
File "/home/marcintustin/django/Django-1.3/django/db/backends/__init__.py", line 46, in _commit
return self.connection.commit()
pysqlite2.dbapi2.OperationalError: cannot commit transaction - SQL statements in progress
基本上,我不知道从哪里开始修复它。有什么想法吗?