From c995ab397c19b956ca91850279798737d4f6b039 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 11 Jan 2012 14:56:12 +0000 Subject: [PATCH] Made suggested cleanups. Refs #121. --- djangorestframework/tests/serializer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/djangorestframework/tests/serializer.py b/djangorestframework/tests/serializer.py index 7cf9325b2..bff8f41e5 100644 --- a/djangorestframework/tests/serializer.py +++ b/djangorestframework/tests/serializer.py @@ -120,13 +120,17 @@ class TestFieldNesting(TestCase): self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}}) self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}}) - def test_serializer_unvalid_hook_method(self): + def test_serializer_overridden_hook_method(self): """ - Test serializing a model instance with an unvalid hook method on the serializer. + Test serializing a model instance which overrides a class method on the + serializer. Checks for correct behaviour in odd edge case. """ class SerializerM2(Serializer): - fields = ('unvalid_hook', ) - def unvalid_hook(self): - return - self.m2.unvalid_hook = 'bla' - self.assertEqual(SerializerM2().serialize_model(self.m2), {'unvalid_hook': 'bla'}) + fields = ('overridden', ) + + def overridden(self): + return False + + self.m2.overridden = True + self.assertEqual(SerializerM2().serialize_model(self.m2), + {'overridden': True})