summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authora1tus <mortas.11@gmail.com>2014-10-21 01:29:28 +0400
committerTim Graham <timograham@gmail.com>2014-10-23 09:49:24 -0400
commit2d75515a4c4fe726e26ebb1a2d2acbc9d047cba6 (patch)
treefb0380ada5e989356d64f27cfe3ab84ac72686e1 /tests
parent70428902c0c4d7660118b935241b54c17f662802 (diff)
Fixed #23444 -- Deprecated django.contrib.admin.helpers.InlineAdminForm.original_content_type_id
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_inlines/tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index 9ed54fd091..e3376fe8e4 100644
--- a/tests/admin_inlines/tests.py
+++ b/tests/admin_inlines/tests.py
@@ -1,11 +1,14 @@
from __future__ import unicode_literals
+import warnings
+
from django.contrib.admin import TabularInline, ModelAdmin
from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
from django.contrib.admin.helpers import InlineAdminForm
from django.contrib.auth.models import User, Permission
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings, RequestFactory
+from django.utils.encoding import force_text
# local test models
from .admin import InnerInline, site as admin_site
@@ -403,6 +406,27 @@ 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:
+ 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 2.0. 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")