Сбой теста Django 1.6.5 перед выполнением тестов

У меня проблема с тестами Django 1.6.5, которые не пройдены до того, как он начнет выполняться.

Если я бегу python manage.py test это терпит неудачу с сообщением ниже:

Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 'test_marks_project'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_marks_project', or 'no' to cancel: yes
Destroying old test database 'default'...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/test/runner.py", line 145, in run_tests
    old_config = self.setup_databases()
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/test/runner.py", line 107, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/test/runner.py", line 279, in setup_databases
    verbosity, autoclobber=not interactive)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/backends/creation.py", line 339, in create_test_db
    load_initial_data=False)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 112, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/core/management/sql.py", line 216, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 101, in create_permissions
    auth_app.Permission.objects.using(db).bulk_create(perms)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/models/query.py", line 359, in bulk_create
    self._batched_insert(objs_without_pk, fields, batch_size)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/models/query.py", line 838, in _batched_insert
    using=self.db)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/models/manager.py", line 232, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/models/query.py", line 1514, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 903, in execute_sql
    cursor.execute(sql, params)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 207, in execute
    if not self._defer_warnings: self._warning_check()
  File "/home/mark/.virtualenvs/marks_project/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 117, in _warning_check
    warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: Data truncated for column 'name' at row 356

Warning: local() encountered an error (return code 1) while executing 'python manage.py test'

До сих пор я не мог понять, что является причиной и как ее решить. Я знаю, что наша база данных может поддерживать только индексы из 191 символа или менее, но не уверен, что это как-то связано с этим.

Изменить я использую UTF8MB4 кодирование в базе данных (для поддержки Emoji и т. д.). Это означает, что мои уникальные поля ограничены 191, а не 255. Не уверен, что это может быть связано.

1 ответ

Решение

max_length Джанго Permission.name это 50:

https://github.com/django/django/blob/1.6c1/django/contrib/auth/models.py

И у вас есть разрешение с именем 'Can delete event participant check in location stats user' длина 57. Вот почему Джанго падает.

Я думаю, что вы можете изменить название ваших разрешений.

Другие вопросы по тегам