Django:DiscoverRunner 覆盖引发错误

Django : DiscoverRunner overriding raise error

我目前正在尝试定义另一个 test_runner。 为此,我更改了 settings.py :

TEST_RUNNER = 'test_runner.MezzoTestsRunner'

这是我的 MezzoTestsRunner class :

class MezzoTestsRunner(DiscoverRunner):

    def __init__(self):
        super(MezzoTestsRunner,self).__init__(keepdb=True)  

然后我使用命令:python manage.py test

  File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 89, in handle
    test_runner = TestRunner(**options)
TypeError: __init__() got an unexpected keyword argument 'verbosity'

我真的很惊讶有这个结果..有人已经有过同样的结果吗?

谢谢:)

PS : 我正在使用 django 1.9

我没有真正解决我的问题,但我可以逃避问题。 我无法在 __init__() 中更改 keepdb,所以我在 run_tests() 方法中进行了更改:

class MezzoTestsRunner(DiscoverRunner):

    def run_tests(self, test_labels, extra_tests=None, **kwargs):
        self.keepdb=True
        super(MezzoTestsRunner,self).run_tests(test_labels,extra_tests, **kwargs)