def test_abstract_model(self):
        class AbstractModel(models.Model):
            afield = models.CharField(max_length=255)

            class Meta:
                abstract = True

        class TestSerializer(serializers.ModelSerializer):
            class Meta:
                model = AbstractModel
                fields = ('afield',)

        serializer = TestSerializer(data={
            'afield': 'foo',
        })
        with self.assertRaises(ValueError) as excinfo:
            serializer.is_valid()
        msginitial = 'Cannot use ModelSerializer with Abstract Models.'
        assert str(excinfo.exception).startswith(msginitial)
Test that trying to use ModelSerializer with Abstract Models
dataset/ETHPy150Open tomchristie/django-rest-framework/tests/test_model_serializer.py/TestModelSerializer.test_abstract_model