aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCarl Meyer2014-10-16 12:16:13 -0600
committerCarl Meyer2014-10-17 09:50:57 -0600
commit140f8620aea44daa368b244d96c68377716fac7e (patch)
treea9be3c9063dcf9e2d9705ce652b7183eac523178 /tests
parent34a7a48c1d0ee72f93aa9ff646192269a0451fd5 (diff)
downloaddjango-rest-framework-140f8620aea44daa368b244d96c68377716fac7e.tar.bz2
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_relations.py5
-rw-r--r--tests/test_serializer.py4
2 files changed, 6 insertions, 3 deletions
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')
diff --git a/tests/test_serializer.py b/tests/test_serializer.py
index 90f37cf2..e72b723f 100644
--- a/tests/test_serializer.py
+++ b/tests/test_serializer.py
@@ -327,7 +327,9 @@ class BasicTests(TestCase):
"""
Regression test for #652.
"""
- self.assertRaises(AssertionError, PersonSerializerInvalidReadOnly, [])
+ serializer = PersonSerializerInvalidReadOnly()
+ with self.assertRaises(AssertionError):
+ serializer.fields
def test_serializer_data_is_cleared_on_save(self):
"""