@@ -130,36 +130,38 @@ def test_user_can_update_self(auth_client, users):
130130@pytest.mark.django_db
131131def test_user_can_update_password(auth_client, users):
132132 url = reverse("users:update", args=[users["alice"].pk])
133+ new_password = "Newpass456"
133134 response = auth_client.post(
134135 url,
135136 data={
136137 "username": "alice",
137138 "first_name": "Alice",
138139 "last_name": "A",
139- "password1": "Newpass456" ,
140- "password2": "Newpass456" ,
140+ "password1": new_password ,
141+ "password2": new_password ,
141142 },
142143 )
143144
144145 assert response.status_code in (302, 301)
145146
146147 users["alice"].refresh_from_db()
147- assert users["alice"].check_password("Newpass456" )
148+ assert users["alice"].check_password(new_password )
148149
149150 fresh_client = Client()
150- assert fresh_client.login(username="alice", password="Newpass456" )
151+ assert fresh_client.login(username="alice", password=new_password )
151152
152153
153154@pytest.mark.django_db
154155def test_user_update_requires_both_password_fields(auth_client, users):
155156 url = reverse("users:update", args=[users["alice"].pk])
157+ password_one = "SinglePass789"
156158 response = auth_client.post(
157159 url,
158160 data={
159161 "username": "alice",
160162 "first_name": "Alice",
161163 "last_name": "A",
162- "password1": "SinglePass789" ,
164+ "password1": password_one ,
163165 "password2": "",
164166 },
165167 )
@@ -172,14 +174,16 @@ def test_user_update_requires_both_password_fields(auth_client, users):
172174@pytest.mark.django_db
173175def test_user_update_password_mismatch(auth_client, users):
174176 url = reverse("users:update", args=[users["alice"].pk])
177+ first_password = "Mismatch111"
178+ second_password = "Mismatch222"
175179 response = auth_client.post(
176180 url,
177181 data={
178182 "username": "alice",
179183 "first_name": "Alice",
180184 "last_name": "A",
181- "password1": "Mismatch111" ,
182- "password2": "Mismatch222" ,
185+ "password1": first_password ,
186+ "password2": second_password ,
183187 },
184188 )
185189
0 commit comments