У меня есть тест, который неисправный с:Как я могу интерактивно исследовать, почему тест терпит неудачу?
======================================================================
FAIL: test_register_should_create_UserProfile (APP.forum.tests.test_views.UserTestCAse)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Bryan/work/app/../app/forum/tests/test_views.py", line 25, in test_register_should_create_UserProfile
self.assertEqual(response.status_code, 200)
AssertionError: 404 != 200
Вот тест:
class UserTestCAse(TestCase):
def test_register_should_create_UserProfile(self):
from django.test.client import Client
c = Client()
# I'm skipping account/signin/ because that requires me to visit Google.
response = c.post('account/signin/complete/', {'username': 'john', "email":'[email protected]', u'bnewaccount': 'Signup'})
# request.POST from pdb() session with breakpoint in register()
# <QueryDict: {u'username': [u'john'], u'email': [u'[email protected]'], u'bnewaccount': [u'Signup']}>
#How do I inspect what is breaking in the test case?
#How do I run the test client in the shell?
self.assertEqual(response.status_code, 200)
user = User.objects.get(username ='john')
self.assertTrue(user.get_profile())
Есть в любом случае, что я могу понять, почему этот ответ не возвращается 200?
Я пытался использовать TestClient() в оболочке, но это не сработало:
In [1]: from django.test.client import Client
In [2]: c = Client()
In [3]: response = c.post('account/signin/complete/', {'username': 'john', "email":'[email protected]', u'bnewaccount': 'Signup'})
---------------------------------------------------------------------------
KeyError: 'tried'
Хороший глаз. «/» Зафиксировал тестовый клиент. Я не могу войти в «pdb» при запуске тестов. В оболочке никогда не отображается запрос pdb. – BryanWheelock