From 140f8620aea44daa368b244d96c68377716fac7e Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 16 Oct 2014 12:16:13 -0600 Subject: Set up serializer fields lazily on-demand. This avoids AppRegistryNotReady problems in Django 1.7 with nested serializers, which are instantiated at import time, possibly before Django's app registry is fully populated. --- tests/test_relations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/test_relations.py') diff --git a/tests/test_relations.py b/tests/test_relations.py index bc1db69f..501a9208 100644 --- a/tests/test_relations.py +++ b/tests/test_relations.py @@ -102,7 +102,7 @@ class RelatedFieldSourceTests(TestCase): self.assertEqual(value, ['BlogPost object']) # Regression for #1129 - def test_exception_for_incorect_fk(self): + def test_exception_for_incorrect_fk(self): """ Check that the exception message are correct if the source field doesn't exist. @@ -123,8 +123,9 @@ class RelatedFieldSourceTests(TestCase): (serializers.ModelSerializer,), attrs ) + serializer = TestSerializer(data={'name': 'foo'}) with self.assertRaises(AttributeError): - TestSerializer(data={'name': 'foo'}) + serializer.fields @unittest.skipIf(get_version() < '1.6.0', 'Upstream behaviour changed in v1.6') -- cgit v1.2.3