                  one_to_one = NestedSerializer(read_only=True):
                      url = HyperlinkedIdentityField(view_name='onetoonetargetmodel-detail')
                      name = CharField(max_length=100)
          """)
          if six.PY2:
              # This case is also too awkward to resolve fully across both py2
              # and py3.  (See above)
              expected = expected.replace(
                  "('foreign_key', 'one_to_one')",
                  "(u'foreign_key', u'one_to_one')"
              )
          self.assertEqual(unicode_repr(TestSerializer()), expected)
  
      def test_pk_reverse_foreign_key(self):
          class TestSerializer(serializers.ModelSerializer):
              class Meta:
                  model = ForeignKeyTargetModel
 
</s> remove         if six.PY2:
            # This particular case is too awkward to resolve fully across
            # both py2 and py3.
            expected = expected.replace(
                "('red', 'Red'), ('blue', 'Blue'), ('green', 'Green')",
                "(u'red', u'Red'), (u'blue', u'Blue'), (u'green', u'Green')"
            )
        self.assertEqual(unicode_repr(TestSerializer()), expected)
 </s> add         self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(unicode_repr(TestSerializer()), expected)
 </s> add         self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(unicode_repr(TestSerializer()), expected)
 </s> add         self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(unicode_repr(TestSerializer()), expected)
 </s> add         self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(unicode_repr(TestSerializer()), expected)
 </s> add         self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
                  one_to_one = NestedSerializer(read_only=True):
                      url = HyperlinkedIdentityField(view_name='onetoonetargetmodel-detail')
                      name = CharField(max_length=100)
          """)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
        self.assertEqual(repr(TestSerializer()), expected)
  
      def test_pk_reverse_foreign_key(self):
          class TestSerializer(serializers.ModelSerializer):
              class Meta:
                  model = ForeignKeyTargetModel
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
tests/test_model_serializer.py