Python 在django allauth中测试更改密码时,不存在任何表单

Python 在django allauth中测试更改密码时,不存在任何表单,python,django,unit-testing,django-allauth,django-webtest,Python,Django,Unit Testing,Django Allauth,Django Webtest,我想写一个测试,将测试更改应用程序中的密码。 我用的是django allauth。 对于测试,我使用django WebTest 当我运行代码时,我会收到以下消息: FAILED (errors=1) Destroying test database for alias 'default'... (urlop)mariusz@mariusz-K73E:~/myapp$ python manage.py test users Creating test database for alias 'd

我想写一个测试,将测试更改应用程序中的密码。 我用的是django allauth。 对于测试,我使用django WebTest

当我运行代码时,我会收到以下消息:

FAILED (errors=1)
Destroying test database for alias 'default'...
(urlop)mariusz@mariusz-K73E:~/myapp$ python manage.py test users
Creating test database for alias 'default'...
.E
======================================================================
ERROR: test_password_change_use_template (myapp.users.tests.ChangePasswordTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mark/myapp/users/tests.py", line 16, in test_password_change_use_template
    password_change.form['oldpassword'] = "test123"
  File "/home/mark/.virtualenvs/urlop/local/lib/python2.7/site-packages/webtest/response.py", line 56, in form
    "You used response.form, but no forms exist")
TypeError: You used response.form, but no forms exist
以下是我的测试代码:

from django_webtest import WebTest
from django_dynamic_fixture import G
from users.models import User
from django.core.urlresolvers import reverse

class ChangePasswordTest(WebTest):
    def setUp(self):
        self.user = G(User)

    def test_password_change_code(self):
        password_change = self.app.get(reverse('account_change_password'), user=self.user)

    def test_password_change_use_template(self):
        password_change = self.app.get(reverse('account_change_password'), user=self.user)
        password_change.form['oldpassword'] = "test123"
        password_change.form['password1'] = "test456"
        password_change.form['password2'] = "test456"
        password_change.form.submit()
        self.assertRedirects(password_change, reverse('change_password'))