summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-09-18 09:56:05 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2013-09-18 10:03:52 +0300
commit50633e7353694ff54f14b04469be3792f286182f (patch)
treefb667696403c6655e787c494abb899ed813bb608 /tests
parent5be56d0e0d8492a41b3d40757a4f2677211a9179 (diff)
Fixed #12568 -- no error when accessing custom field's descriptor
The SubfieldBase's descriptor caused an AttributeError when accessed from the class. Introspection didn't like that. Patch by Trac alias supervacuo.
Diffstat (limited to 'tests')
-rw-r--r--tests/field_subclassing/tests.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/field_subclassing/tests.py b/tests/field_subclassing/tests.py
index d3b4d9e527..3045f7d226 100644
--- a/tests/field_subclassing/tests.py
+++ b/tests/field_subclassing/tests.py
@@ -1,5 +1,7 @@
from __future__ import unicode_literals
+import inspect
+
from django.core import serializers
from django.test import TestCase
@@ -74,7 +76,7 @@ class CustomField(TestCase):
m.delete()
m1 = MyModel.objects.create(name="1", data=Small(1, 2))
- m2 = MyModel.objects.create(name="2", data=Small(2, 3))
+ MyModel.objects.create(name="2", data=Small(2, 3))
self.assertQuerysetEqual(
MyModel.objects.all(), [
@@ -90,3 +92,15 @@ class CustomField(TestCase):
o = OtherModel.objects.get()
self.assertEqual(o.data.first, "a")
self.assertEqual(o.data.second, "b")
+
+ def test_subfieldbase_plays_nice_with_module_inspect(self):
+ """
+ Custom fields should play nice with python standard module inspect.
+
+ http://users.rcn.com/python/download/Descriptor.htm#properties
+ """
+ # Even when looking for totally different properties, SubfieldBase's
+ # non property like behaviour made inspect crash. Refs #12568.
+ data = dict(inspect.getmembers(MyModel))
+ self.assertIn('__module__', data)
+ self.assertEqual(data['__module__'], 'field_subclassing.models')