开发者

Django unit tests spews database error - cannot commit transaction - SQL statements in progress

I'm using unittest2 together with manage.py test, and before it even seems to run any tests, it spews a horrid database error, as below. I'm in my development environment (actually on a dreamhost server for a variety of reasons), using sqlite as my database.

Even when I copy my app out of where it is for production (and edit settings.py accordingly), I still get the same error (even though it should no longer be addressing the same database file as the dev environment).

Update: Even moving all instances of my database files to a different filename still leaves me with the same error. This leads me to believe that the test environment is somehow looking at a bogus database, or something very odd is happening.

[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

Basically, I have no idea where to start with fixing this. Any ideas?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜