Django在开始测试时得到django.db.utils.ProgrammingError

时间:2016-02-09 21:31:43

标签: python django postgresql django-testing

当我开始测试时,我收到错误

~/work/some_project$ ./manage.py test
Raven is not configured (logging is disabled). Please see the documentation for more information.
/Users/ioganegambaputi/work/some_project/some_project/core/forms.py:7: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
  from django.forms.util import ErrorList

/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/templated_email/__init__.py:2: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils.importlib import import_module

/Users/ioganegambaputi/work/some_project/some_project/core/utils.py:50: RemovedInDjango19Warning: 'get_cache' is deprecated in favor of 'caches'.
  self.cache = cache.get_cache(cache_alias or cache.DEFAULT_CACHE_ALIAS)

Creating test database for alias 'default'...
Got an error creating the test database: database "test_some_project" already exists

Type 'yes' if you would like to try deleting the test database 'test_some_project', or 'no' to cancel: yes
Destroying old test database 'default'...
/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/loaddata.py:229: RemovedInDjango19Warning: initial_data fixtures are deprecated. Use data migrations instead.
  RemovedInDjango19Warning

Traceback (most recent call last):
  File "./manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 368, in create_test_db
    test_flush=not keepdb,
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 365, in sync_apps
    hide_empty=True,
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 37, in new_execute
    return original_func(self, *args, **kwargs)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 60, in handle
    self.loaddata(fixture_labels)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 90, in loaddata
    self.load_label(fixture_label)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 147, in load_label
    obj.save(using=self.using)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/core/serializers/base.py", line 173, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/base.py", line 827, in _save_table
    forced_update)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/base.py", line 877, in _do_update
    return filtered._update(values) > 0
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/query.py", line 580, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1062, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
    cursor.execute(sql, params)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/ioganegambaputi/work/env/some_project/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError

当我在localhost上运行我的应用程序时 - 一切正常,只有测试才会发生。这是我的设置

DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'some_project',
          'USER': 'web',
          'PASSWORD': '',
          'HOST': ''
      }
}

我使用Django == 1.8.4和psql(PostgreSQL)9.4.1。 我打开了数据库日志,并且没有在控制台上打印出任何内容,但是当应用程序正常运行时,它运行良好。

此外,我授予了网络用户超级用户权限。

出了什么问题?如何在没有手动调试的情况下获取更多日志?

0 个答案:

没有答案