1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Refs #24121 -- Added __repr__() to AdminForm, BlockContext, BlockTranslateNode, and IncludeNode.

This commit is contained in:
saeedblanchette
2021-06-08 17:00:00 +01:00
committed by Mariusz Felisiak
parent cb6c19749d
commit 66ed03e7c9
7 changed files with 80 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.admin.helpers import AdminForm
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.test import SimpleTestCase, TestCase, override_settings
from .admin import ArticleForm
# To verify that the login form rejects inactive users, use an authentication
@@ -18,3 +21,21 @@ class AdminAuthenticationFormTests(TestCase):
}
form = AdminAuthenticationForm(None, data)
self.assertEqual(form.non_field_errors(), ['This account is inactive.'])
class AdminFormTests(SimpleTestCase):
def test_repr(self):
fieldsets = (
('My fields', {
'classes': ['collapse'],
'fields': ('url', 'title', 'content', 'sites'),
}),
)
form = ArticleForm()
admin_form = AdminForm(form, fieldsets, {})
self.assertEqual(
repr(admin_form),
"<AdminForm: form=ArticleForm fieldsets=(('My fields', "
"{'classes': ['collapse'], "
"'fields': ('url', 'title', 'content', 'sites')}),)>",
)