这对我来说没有任何意义,当论证相同时,断言如何失败?
======================================================================
FAIL: test_register_page_redirects_to_signin_page (forum.tests.test_views.ForumTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Bryan/work/osqa/forum/tests/test_views.py", line 19, in test_register_page_redirects_to_signin_page
self.assertRedirects(response, '/accounts/signin/')
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/django/test/testcases.py", line 345, in assertRedirects
(url, expected_url))
AssertionError: Response redirected to 'http://testserver/account/signin/', expected 'http://testserver/accounts/signin/'
以下是测试:
class ForumTestCase(TestCase):
def test_register_page_redirects_to_signin_page(self):
response = self.client.get('/account/register/', follow=True)
self.assertRedirects(response, '/accounts/signin/')
self.assertTemplateUsed(response, "auth/signin.html")
self.assertEqual(response.status_code, 200)
答案 0 :(得分:8)
它们并不完全相同......你确定这一行
self.assertRedirects(response, '/accounts/signin/')
不应该
self.assertRedirects(response, '/account/signin/')
答案 1 :(得分:6)
因为你的论点...... 不是相同吗?
http://testserver/account/signin/
http://testserver/accounts/signin/
^