下面的自定义中间件处于活动状态时,在我运行python manage.py test
时会导致此测试失败。我们运行的是Django 1.5.4:
FAIL: test_naturalday_uses_localtime (django.contrib.humanize.tests.HumanizeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/endaga-server/local/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 161, in test_naturalday_uses_localtime
self.humanize_tester([dt], ['yesterday'], 'naturalday')
File "/home/vagrant/.virtualenvs/endaga-server/local/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
AssertionError: naturalday test failed, produced 'today', should've produced 'yesterday'
有问题的中间件:
^{pr2}$如何修改这个中间件以使测试不会失败?在
你可能做不到。你可以在测试期间模拟它,或者确保用户的时区与运行测试的时区相同。在
相关问题 更多 >
编程相关推荐