diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_changelist/tests.py | 6 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 26 |
2 files changed, 24 insertions, 8 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 7f3f0d162e..fb72f60b7c 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -91,7 +91,7 @@ class ChangeListTests(TestCase): context = Context({'cl': cl}) table_output = template.render(context) link = reverse('admin:admin_changelist_child_change', args=(new_child.id,)) - row_html = '<tbody><tr class="row1"><th><a href="%s">name</a></th><td class="nowrap">(None)</td></tr></tbody>' % link + row_html = '<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th><td class="field-parent nowrap">(None)</td></tr></tbody>' % link self.assertFalse(table_output.find(row_html) == -1, 'Failed to find expected row element: %s' % table_output) @@ -114,7 +114,7 @@ class ChangeListTests(TestCase): context = Context({'cl': cl}) table_output = template.render(context) link = reverse('admin:admin_changelist_child_change', args=(new_child.id,)) - row_html = '<tbody><tr class="row1"><th><a href="%s">name</a></th><td class="nowrap">Parent object</td></tr></tbody>' % link + row_html = '<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th><td class="field-parent nowrap">Parent object</td></tr></tbody>' % link self.assertFalse(table_output.find(row_html) == -1, 'Failed to find expected row element: %s' % table_output) @@ -150,7 +150,7 @@ class ChangeListTests(TestCase): # make sure that list editable fields are rendered in divs correctly editable_name_field = '<input name="form-0-name" value="name" class="vTextField" maxlength="30" type="text" id="id_form-0-name" />' - self.assertInHTML('<td>%s</td>' % editable_name_field, table_output, msg_prefix='Failed to find "name" list_editable field') + self.assertInHTML('<td class="field-name">%s</td>' % editable_name_field, table_output, msg_prefix='Failed to find "name" list_editable field') def test_result_list_editable(self): """ diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 7decf6f471..80fdb90402 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1496,7 +1496,7 @@ class AdminViewStringPrimaryKeyTest(TestCase): response = self.client.get(prefix) # this URL now comes through reverse(), thus url quoting and iri_to_uri encoding pk_final_url = escape(iri_to_uri(urlquote(quote(self.pk)))) - should_contain = """<th><a href="%s%s/">%s</a></th>""" % (prefix, pk_final_url, escape(self.pk)) + should_contain = """<th class="field-__str__"><a href="%s%s/">%s</a></th>""" % (prefix, pk_final_url, escape(self.pk)) self.assertContains(response, should_contain) def test_recentactions_link(self): @@ -2151,8 +2151,8 @@ class AdminViewListEditable(TestCase): self.assertContains(response, 'id="id_form-0-id"', 1) # Only one hidden field, in a separate place than the table. self.assertContains(response, 'id="id_form-1-id"', 1) self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="%d" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="%d" id="id_form-1-id" />\n</div>' % (story2.id, story1.id), html=True) - self.assertContains(response, '<td>%d</td>' % story1.id, 1) - self.assertContains(response, '<td>%d</td>' % story2.id, 1) + self.assertContains(response, '<td class="field-id">%d</td>' % story1.id, 1) + self.assertContains(response, '<td class="field-id">%d</td>' % story2.id, 1) def test_pk_hidden_fields_with_list_display_links(self): """ Similarly as test_pk_hidden_fields, but when the hidden pk fields are @@ -2167,8 +2167,8 @@ class AdminViewListEditable(TestCase): self.assertContains(response, 'id="id_form-0-id"', 1) # Only one hidden field, in a separate place than the table. self.assertContains(response, 'id="id_form-1-id"', 1) self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="%d" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="%d" id="id_form-1-id" />\n</div>' % (story2.id, story1.id), html=True) - self.assertContains(response, '<th><a href="%s">%d</a></th>' % (link1, story1.id), 1) - self.assertContains(response, '<th><a href="%s">%d</a></th>' % (link2, story2.id), 1) + self.assertContains(response, '<th class="field-id"><a href="%s">%d</a></th>' % (link1, story1.id), 1) + self.assertContains(response, '<th class="field-id"><a href="%s">%d</a></th>' % (link2, story2.id), 1) @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) @@ -3877,6 +3877,22 @@ class CSSTest(TestCase): self.assertContains(response, '<body class="app-admin_views model-section ') + def test_changelist_field_classes(self): + """ + Cells of the change list table should contain the field name in their class attribute + Refs #11195. + """ + Podcast.objects.create(name="Django Dose", + release_date=datetime.date.today()) + response = self.client.get('/test_admin/admin/admin_views/podcast/') + self.assertContains( + response, '<th class="field-name">') + self.assertContains( + response, '<td class="field-release_date nowrap">') + self.assertContains( + response, '<td class="action-checkbox">') + + try: import docutils except ImportError: |
