Skip to content

Commit 1019cc7

Browse files
committed
Check for the admin password change view url in the test
This should work both for pre-5.0 and post-5.0 versions of Django.
1 parent a99a6ff commit 1019cc7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

tests/tests/tests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from unittest import skipIf, skipUnless
44

5+
import django
56
from django.core import mail
67

78
from django.test import TestCase
@@ -257,7 +258,15 @@ def test_better_readonly_password_widget(self):
257258
form = UserChangeForm(instance=user)
258259

259260
self.assertIn(_('*************'), form.as_table())
260-
self.assertIn('<a class="button"', form.as_table())
261+
262+
version = django.VERSION[0]
263+
264+
if version < 4:
265+
self.assertIn('<a href="../password/">', form.as_table())
266+
elif version < 5:
267+
self.assertIn('<a href="../../{0}/password/">'.format(user.id), form.as_table())
268+
else:
269+
self.assertIn('<a class="button" href="../password/">', form.as_table())
261270

262271

263272
class UserAdminTest(TestCase):

0 commit comments

Comments
 (0)