Django 1.8:" ./ manage.py test"因类型错误而失败:不支持的操作数类型 - :' unicode'和' int'

时间:2015-04-27 11:13:34

标签: django-testing django-1.8

(mathspace)pzrq@Peters-Mac-mini:~/Projects/mathspace$ ./manage.py test
Creating test database for alias 'default' (':memory:')...
Traceback (most recent call last):
  File "./manage.py", line 20, in 
    execute_from_command_line(sys.argv)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/pzrq/.virtualenvs/mathspace/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/pzrq/.virtualenvs/mathspace/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/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/test_without_migrations/management/commands/test.py", line 28, in handle
    super(Command, self).handle(*test_labels, **options)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/Users/pzrq/.virtualenvs/mathspace/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/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 365, in create_test_db
    verbosity=max(verbosity - 1, 0),
TypeError: unsupported operand type(s) for -: 'unicode' and 'int'

1 个答案:

答案 0 :(得分:0)

修正:

pip uninstall django-test-without-migrations

我猜这是由django-test-without-migrations的旧版本引起的,不尊重Django 1.8中的optparse到argparse更新,所以我后来确定你也可以用以下方法修复它:

pip install --upgrade django-test-without-migrations