diff options
| author | Adam Johnson <me@adamj.eu> | 2017-06-04 22:58:24 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-05 08:40:43 -0400 |
| commit | ed244199c72f5bbf33ab4547e06e69873d7271d0 (patch) | |
| tree | 727afbd26e655449ebcd007fe5f64333dd2b9711 /tests/model_meta | |
| parent | 36f09c8a29eaad6a7e903ddc3ea1e8b5954ee67a (diff) | |
Fixed #28269 -- Fixed Model.__init__() crash on models with a field that has an instance only descriptor.
Regression in d2a26c1a90e837777dabdf3d67ceec4d2a70fb86.
Diffstat (limited to 'tests/model_meta')
| -rw-r--r-- | tests/model_meta/models.py | 9 | ||||
| -rw-r--r-- | tests/model_meta/tests.py | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/model_meta/models.py b/tests/model_meta/models.py index 882ac2c9fd..bd7e7f1889 100644 --- a/tests/model_meta/models.py +++ b/tests/model_meta/models.py @@ -9,6 +9,13 @@ class Relation(models.Model): pass +class InstanceOnlyDescriptor(object): + def __get__(self, instance, cls=None): + if instance is None: + raise AttributeError('Instance only') + return 1 + + class AbstractPerson(models.Model): # DATA fields data_abstract = models.CharField(max_length=10) @@ -43,6 +50,8 @@ class AbstractPerson(models.Model): def test_property(self): return 1 + test_instance_only_descriptor = InstanceOnlyDescriptor() + class BasePerson(AbstractPerson): # DATA fields diff --git a/tests/model_meta/tests.py b/tests/model_meta/tests.py index 752bf4fc67..b62fff01bd 100644 --- a/tests/model_meta/tests.py +++ b/tests/model_meta/tests.py @@ -276,4 +276,6 @@ class ParentListTests(SimpleTestCase): class PropertyNamesTests(SimpleTestCase): def test_person(self): + # Instance only descriptors don't appear in _property_names. + self.assertEqual(AbstractPerson().test_instance_only_descriptor, 1) self.assertEqual(AbstractPerson._meta._property_names, frozenset(['pk', 'test_property'])) |
