Skip to content

Commit 542d506

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 542d506

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/tests/tests.py

Lines changed: 7 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
@@ -11,6 +12,7 @@
1112
from django.forms.fields import Field
1213
from django.conf import settings
1314
from django.contrib.auth import get_user_model
15+
from django.urls import reverse
1416

1517
from authtools.admin import BASE_FIELDS
1618
from authtools.forms import (
@@ -257,7 +259,11 @@ def test_better_readonly_password_widget(self):
257259
form = UserChangeForm(instance=user)
258260

259261
self.assertIn(_('*************'), form.as_table())
260-
self.assertIn('<a class="button"', form.as_table())
262+
263+
if django.get_version()[0] < 5:
264+
self.assertIn('<a class="button" href="../password/">', form.as_table())
265+
else:
266+
self.assertIn('<a href="../../{0}/password/">'.format(user.id), form.as_table())
261267

262268

263269
class UserAdminTest(TestCase):

0 commit comments

Comments
 (0)