【问题标题】:Django 1.8: "./manage.py test" fails with TypeError: unsupported operand type(s) for -: 'unicode' and 'int'Django 1.8:“./manage.py 测试”因 TypeError 失败:不支持的操作数类型为 -: 'unicode' 和 'int'
【发布时间】:2015-07-05 19:30:44
【问题描述】:
(数学空间)pzrq@Peters-Mac-mini:~/Projects/mathspace$ ./manage.py 测试 为别名 'default' (':memory:') 创建测试数据库... 回溯(最近一次通话最后): 文件“./manage.py”,第 20 行,在 execute_from_command_line(sys.argv) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/__init__.py”,第 338 行,在 execute_from_command_line 实用程序.execute() 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/__init__.py”,第330行,在执行 self.fetch_command(子命令).run_from_argv(self.argv) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/commands/test.py”,第 30 行,在 run_from_argv 超级(命令,自我).run_from_argv(argv) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/base.py”,第 390 行,在 run_from_argv self.execute(*args, **cmd_options) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/commands/test.py”,第74行,在执行 super(Command, self).execute(*args, **options) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/base.py”,第 441 行,在执行 输出 = self.handle(*args, **options) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/test_without_migrations/management/commands/test.py”,第 28 行,在句柄中 super(Command, self).handle(*test_labels, **options) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/core/management/commands/test.py”,第 90 行,在句柄中 失败 = test_runner.run_tests(test_labels) 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/test/runner.py”,第 210 行,在 run_tests old_config = self.setup_databases() setup_databases 中的文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/test/runner.py”,第 166 行 **kwargs setup_databases 中的文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/test/runner.py”,第 370 行 serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True), 文件“/Users/pzrq/.virtualenvs/mathspace/lib/python2.7/site-packages/django/db/backends/base/creation.py”,第 365 行,在 create_test_db 详细度=最大(详细度 - 1, 0), TypeError: 不支持的操作数类型 -: 'unicode' 和 'int'

【问题讨论】:

    标签: django-testing django-1.8


    【解决方案1】:

    修正者:

    pip uninstall django-test-without-migrations
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 2012-09-06
      • 2017-12-27
      • 2014-03-31
      相关资源
      最近更新 更多