Django manage.py测试失败(django.contrib.messages.middleware.MessageMiddleware)

时间:2013-05-11 02:36:31

标签: python django unit-testing

运行manage.py test后,我反复得到这个:

    ERROR 4280 140735184636256 base: Internal Server Error: /add/error/
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/django/contrib/messages/tests/urls.py", line 30, in add
    getattr(messages, message_type)(request, msg)
  File "/Library/Python/2.7/site-packages/django/contrib/messages/api.py", line 102, in error
    fail_silently=fail_silently)
  File "/Library/Python/2.7/site-packages/django/contrib/messages/api.py", line 22, in add_message
    raise MessageFailure('You cannot add messages without installing '
MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware

在我的settings.py中启用了MessageMiddleware,因此不确定原因。任何线索?

1 个答案:

答案 0 :(得分:0)

您正在运行所有已定义的测试,包括django自己的测试。指定要测试的模块:

python manage.py test my_app my_other_app