#NEWLINE# def test_create_method( self ) : #NEWLINE# #INDENT# class TestSerializer ( serializers . ModelSerializer ) : #NEWLINE# #INDENT# non_model_field = serializers . CharField ( ) #NEWLINE# class Meta ( ) : #NEWLINE# #INDENT# model = OneFieldModel #NEWLINE# fields = ( 'char_field' , 'non_model_field' ) #NEWLINE# #UNINDENT# #UNINDENT# serializer = TestSerializer ( data = { #NEWLINE# #INDENT# 'char_field' : 'foo' , #NEWLINE# 'non_model_field' : 'bar' , #NEWLINE# #UNINDENT# } ) #NEWLINE# serializer . is_valid ( ) #NEWLINE# with self . assertRaises ( TypeError ) as excinfo : #NEWLINE# #INDENT# serializer . save ( ) #NEWLINE# #UNINDENT# msginitial = 'Got a `TypeError` when calling `OneFieldModel.objects.create()`.' #NEWLINE# assert str ( excinfo . exception ) . startswith ( msginitial )