1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #26320 -- Removed implicit OneToOnField parent_link per deprecation timeline.

This commit is contained in:
Tim Graham
2016-12-31 12:30:29 -05:00
parent 1691782652
commit 9d0e8c1e7f
3 changed files with 9 additions and 19 deletions

View File

@@ -2,11 +2,11 @@
from __future__ import unicode_literals
import unittest
import warnings
from django.conf import settings
from django.core.checks import Error
from django.core.checks.model_checks import _check_lazy_references
from django.core.exceptions import ImproperlyConfigured
from django.db import connections, models
from django.db.models.signals import post_init
from django.test import SimpleTestCase
@@ -783,26 +783,14 @@ class OtherModelTests(SimpleTestCase):
self.assertEqual(errors, expected)
def test_missing_parent_link(self):
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always')
msg = 'Add parent_link=True to invalid_models_tests.ParkingLot.parent.'
with self.assertRaisesMessage(ImproperlyConfigured, msg):
class Place(models.Model):
pass
class ParkingLot(Place):
# In lieu of any other connector, an existing OneToOneField will be
# promoted to the primary key.
parent = models.OneToOneField(Place, models.CASCADE)
self.assertEqual(len(warns), 1)
msg = str(warns[0].message)
self.assertEqual(
msg,
'Add parent_link=True to invalid_models_tests.ParkingLot.parent '
'as an implicit link is deprecated.'
)
self.assertEqual(ParkingLot._meta.pk.name, 'parent')
def test_m2m_table_name_clash(self):
class Foo(models.Model):
bar = models.ManyToManyField('Bar', db_table='myapp_bar')