我正在尝试django-lean,我的行为很奇怪,有时显示测试或控制,但有时显示两者或两者都没有(对于同一请求)。
我用./manage.py test experimets
运行测试,两次测试失败:
======================================================================
FAIL: testIntegrationWithAnonymousVisitor (experiments.tests.test_tags.ExperimentTagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/dev/skin/experiments/tests/test_tags.py", line 35, in testIntegrationWithAnonymousVisitor
client_factory=lambda i: Client())
File "/home/ubuntu/dev/skin/experiments/tests/test_tags.py", line 76, in doTestIntegration
self.assertTrue(in_test != in_control)
AssertionError: False is not true
======================================================================
FAIL: testIntegrationWithRegisteredUser (experiments.tests.test_tags.ExperimentTagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/dev/skin/experiments/tests/test_tags.py", line 55, in testIntegrationWithRegisteredUser
client_factory=create_registered_user_client)
File "/home/ubuntu/dev/skin/experiments/tests/test_tags.py", line 76, in doTestIntegration
self.assertTrue(in_test != in_control)
AssertionError: False is not true
这到底是怎么回事?
答案 0 :(得分:1)
我自己遇到了同样的问题..解决方案在文档中是正确的:
确保django.core.context_processors.request位于settings.py中的
TEMPLATE_CONTEXT_PROCESSORS
这应该在您的settings.py
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request",
)