          self.assertEquals(self.serialize({'items': 'foo'}), {'items': u'foo'})
          self.assertEquals(self.serialize({'keys': 'foo'}), {'keys': u'foo'})
          self.assertEquals(self.serialize({'values': 'foo'}), {'values': u'foo'})
  
      def test_ugettext_lazy(self):
          self.assertEquals(self.serialize(ugettext_lazy('foobar')), u'foobar')
  
  
  class TestFieldNesting(TestCase):
      """
      Test nesting the fields in the Serializer class
      """
      def setUp(self):
          self.serializer = Serializer()
          self.serialize = self.serializer.serialize
  
          class M1(models.Model):
              field1 = models.CharField(max_length=256)
              field2 = models.CharField(max_length=256)
  
          class M2(models.Model):
              field = models.OneToOneField(M1)
  
          class M3(models.Model):
              field = models.ForeignKey(M1)
  
          self.m1 = M1(field1='foo', field2='bar')
          self.m2 = M2(field=self.m1)
          self.m3 = M3(field=self.m1)
  
  
      def test_tuple_nesting(self):
          """
          Test tuple nesting on `fields` attr
          """
          class SerializerM2(Serializer):
              fields = (('field', ('field1',)),)
  
          class SerializerM3(Serializer):
              fields = (('field', ('field2',)),)
  
          self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
          self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})
  
  
      def test_serializer_class_nesting(self):
          """
          Test related model serialization
          """
          class NestedM2(Serializer):
              fields = ('field1', )
  
          class NestedM3(Serializer):
              fields = ('field2', )
  
          class SerializerM2(Serializer):
              fields = [('field', NestedM2)]
  
          class SerializerM3(Serializer):
              fields = [('field', NestedM3)]
  
          self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
          self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})
  
      def test_serializer_no_fields(self):
          """
          Test related serializer works when the fields attr isn't present. Fix for
          #178.
 
</s> remove         self.m2.overridden = True
        self.assertEqual(SerializerM2().serialize_model(self.m2),
                         {'overridden': True})
 </s> add #         class M1(models.Model):
#             field1 = models.CharField(max_length=256)
#             field2 = models.CharField(max_length=256)

#         class M2(models.Model):
#             field = models.OneToOneField(M1)

#         class M3(models.Model):
#             field = models.ForeignKey(M1)

#         self.m1 = M1(field1='foo', field2='bar')
#         self.m2 = M2(field=self.m1)
#         self.m3 = M3(field=self.m1)


#     def test_tuple_nesting(self):
#         """
#         Test tuple nesting on `fields` attr
#         """
#         class SerializerM2(Serializer):
#             fields = (('field', ('field1',)),)

#         class SerializerM3(Serializer):
#             fields = (('field', ('field2',)),)

#         self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
#         self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})


#     def test_serializer_class_nesting(self):
#         """
#         Test related model serialization
#         """
#         class NestedM2(Serializer):
#             fields = ('field1', )

#         class NestedM3(Serializer):
#             fields = ('field2', )

#         class SerializerM2(Serializer):
#             fields = [('field', NestedM2)]

#         class SerializerM3(Serializer):
#             fields = [('field', NestedM3)]

#         self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
#         self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})

#     def test_serializer_no_fields(self):
#         """
#         Test related serializer works when the fields attr isn't present. Fix for
#         #178.
#         """
#         class NestedM2(Serializer):
#             fields = ('field1', )

#         class NestedM3(Serializer):
#             fields = ('field2', )

#         class SerializerM2(Serializer):
#             include = [('field', NestedM2)]
#             exclude = ('id', )

#         class SerializerM3(Serializer):
#             fields = [('field', NestedM3)]

#         self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
#         self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})

#     def test_serializer_classname_nesting(self):
#         """
#         Test related model serialization
#         """
#         class SerializerM2(Serializer):
#             fields = [('field', 'NestedM2')]

#         class SerializerM3(Serializer):
#             fields = [('field', 'NestedM3')]

#         class NestedM2(Serializer):
#             fields = ('field1', )

#         class NestedM3(Serializer):
#             fields = ('field2', )

#         self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
#         self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})

#     def test_serializer_overridden_hook_method(self):
#         """
#         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 = ('overridden', )

#             def overridden(self):
#                 return False

#         self.m2.overridden = True
#         self.assertEqual(SerializerM2().serialize_model(self.m2),
#                          {'overridden': True}) </s> remove         class NestedM3(Serializer):
            fields = ('field2', )

        class SerializerM2(Serializer):
            include = [('field', NestedM2)]
            exclude = ('id', )

        class SerializerM3(Serializer):
            fields = [('field', NestedM3)]

        self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
        self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})
 </s> add #     def setUp(self):
#         self.serializer = Serializer()
#         self.serialize = self.serializer.serialize </s> remove     def test_serializer_no_fields(self):
        """
        Test related serializer works when the fields attr isn't present. Fix for
        #178.
        """
        class NestedM2(Serializer):
            fields = ('field1', )
 </s> add # class TestObjectToData(TestCase):
#     """
#     Tests for the Serializer class.
#     """ </s> remove         class NestedM3(Serializer):
            fields = ('field2', )
 </s> add #     def test_dict_method_name_collision(self):
#         """dict with key that collides with dict method name"""
#         self.assertEquals(self.serialize({'items': 'foo'}), {'items': u'foo'})
#         self.assertEquals(self.serialize({'keys': 'foo'}), {'keys': u'foo'})
#         self.assertEquals(self.serialize({'values': 'foo'}), {'values': u'foo'}) </s> remove     def test_serializer_classname_nesting(self):
        """
        Test related model serialization
        """
        class SerializerM2(Serializer):
            fields = [('field', 'NestedM2')]
 </s> add #     def test_decimal(self):
#         """Decimals need to be converted to a string representation."""
#         self.assertEquals(self.serialize(decimal.Decimal('1.5')), decimal.Decimal('1.5'))
          self.assertEquals(self.serialize({'items': 'foo'}), {'items': u'foo'})
          self.assertEquals(self.serialize({'keys': 'foo'}), {'keys': u'foo'})
          self.assertEquals(self.serialize({'values': 'foo'}), {'values': u'foo'})
  



























































  
      def test_serializer_no_fields(self):
          """
          Test related serializer works when the fields attr isn't present. Fix for
          #178.
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Drop out resources & mixins 
djangorestframework/tests/serializer.py