django测试创建基础失败

时间:2014-12-07 09:44:27

标签: python django unit-testing testing

我正在尝试运行test,manage.py test或manage.py test“app_name”但是在创建db时失败了。现在我从测试中删除了所有代码,并继续获得相同的错误

TypeError: expected string or buffer

我的追溯

 Traceback (most recent call last):
  File "manage.py", line 16, in <module>
    execute_from_command_line(sys.argv)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/test/runner.py", line 147, in run_tests
    old_config = self.setup_databases()
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/test/runner.py", line 109, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/test/runner.py", line 299, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/backends/creation.py", line 377, in create_test_db
    test_flush=True,
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 115, in call_command
    return klass.execute(*args, **defaults)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/migrations/executor.py", line 63, in migrate
    self.apply_migration(migration, fake=fake)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/migrations/executor.py", line 97, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/migrations/migration.py", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 139, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/backends/schema.py", line 473, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/backends/schema.py", line 558, in _alter_field
    new_default = self.effective_default(new_field)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/backends/schema.py", line 184, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 627, in get_db_prep_save
    prepared=False)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1176, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1171, in get_prep_value
    return self.to_python(value)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1128, in to_python
    parsed = parse_date(value)
  File "/var/www/html/auction/venv/lib/python3.4/site-packages/django/utils/dateparse.py", line 37, in parse_date
    match = date_re.match(value)
TypeError: expected string or buffer

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

问题在于迁移不良,某些字段的值不正确