mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #23444 -- Removed InlineAdminForm.original_content_type_id per deprecation timeline.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
import warnings
|
||||
|
||||
from django.contrib.admin import ModelAdmin, TabularInline
|
||||
from django.contrib.admin.helpers import InlineAdminForm
|
||||
@@ -10,7 +9,6 @@ from django.contrib.auth.models import Permission, User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import RequestFactory, TestCase, override_settings
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from .admin import InnerInline, site as admin_site
|
||||
from .models import (
|
||||
@@ -458,28 +456,6 @@ class TestInlineAdminForm(TestCase):
|
||||
parent_ct = ContentType.objects.get_for_model(Parent)
|
||||
self.assertEqual(iaf.original.content_type, parent_ct)
|
||||
|
||||
def test_original_content_type_id_deprecated(self):
|
||||
"""
|
||||
#23444 -- Verify a warning is raised when accessing
|
||||
`original_content_type_id` attribute of `InlineAdminForm` object.
|
||||
"""
|
||||
iaf = InlineAdminForm(None, None, {}, {}, None)
|
||||
poll = Poll.objects.create(name="poll")
|
||||
iaf2 = InlineAdminForm(None, None, {}, {}, poll)
|
||||
poll_ct = ContentType.objects.get_for_model(Poll)
|
||||
with warnings.catch_warnings(record=True) as recorded:
|
||||
warnings.filterwarnings('always')
|
||||
with self.assertRaises(AttributeError):
|
||||
iaf.original_content_type_id
|
||||
msg = force_text(recorded.pop().message)
|
||||
self.assertEqual(
|
||||
msg,
|
||||
'InlineAdminForm.original_content_type_id is deprecated and will be '
|
||||
'removed in Django 1.10. If you were using this attribute to construct '
|
||||
'the "view on site" URL, use the `absolute_url` attribute instead.'
|
||||
)
|
||||
self.assertEqual(iaf2.original_content_type_id, poll_ct.id)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
|
||||
ROOT_URLCONF="admin_inlines.urls")
|
||||
|
||||
Reference in New Issue
Block a user