1

我正在尝试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

这到底是怎么回事?

4

1 回答 1

1

我自己也遇到了同样的问题。解决方案在文档中是正确的:

确保 django.core.context_processors.requestTEMPLATE_CONTEXT_PROCESSORS在 settings.py

这应该在你的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",
  )
于 2014-01-26T20:22:31.273 回答