我目前正在尝试定义其他test_runner。
为此,我更改了settings.py
:
TEST_RUNNER = 'test_runner.MezzoTestsRunner'
这是我的MezzoTestsRunner
课程:
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
答案 0 :(得分:0)
我没有真正解决我的问题,但我可以解决问题。
我无法更改keepdb
中的__init__()
,因此我在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)