Skip to content

Commit 2833e7e

Browse files
committed
Update form tests to work with Django 4.1
1 parent 75faacc commit 2833e7e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

password_policies/tests/test_views.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def test_password_change_failure(self):
5151
response = self.client.post(reverse("password_change"), data=data)
5252
self.assertEqual(response.status_code, 200)
5353
self.assertFalse(response.context["form"].is_valid())
54-
self.assertFormError(response, "form", field="old_password", errors=msg)
54+
if DJANGO_VERSION > (4, 1):
55+
self.assertFormError(response.context["form"], field="old_password", errors=msg)
56+
else:
57+
self.assertFormError(response, "form", field="old_password", errors=msg)
5558
self.client.logout()
5659

5760
def test_password_change_success(self):
@@ -108,7 +111,10 @@ def test_password_change_wrong_validators(self):
108111
response = self.client.post(reverse("password_change"), data=data)
109112
self.assertEqual(response.status_code, 200)
110113
self.assertFalse(response.context["form"].is_valid())
111-
self.assertFormError(response, "form", field="new_password2", errors=msg)
114+
if DJANGO_VERSION > (4, 1):
115+
self.assertFormError(response.context["form"], field="new_password2", errors=msg)
116+
else:
117+
self.assertFormError(response, "form", field="new_password2", errors=msg)
112118
self.client.logout()
113119

114120
def test_password_reset_complete(self):

0 commit comments

Comments
 (0)