@@ -74,7 +74,8 @@ def method(self):
7474
7575
7676COLOR_CHOICES  =  (('red' , 'Red' ), ('blue' , 'Blue' ), ('green' , 'Green' ))
77- DECIMAL_CHOICES  =  (('low' , decimal .Decimal ('0.1' )), ('medium' , decimal .Decimal ('0.5' )), ('high' , decimal .Decimal ('0.9' )))
77+ DECIMAL_CHOICES  =  (
78+ ('low' , decimal .Decimal ('0.1' )), ('medium' , decimal .Decimal ('0.5' )), ('high' , decimal .Decimal ('0.9' )))
7879
7980
8081class  FieldOptionsModel (models .Model ):
@@ -88,7 +89,8 @@ class FieldOptionsModel(models.Model):
8889
8990
9091class  ChoicesModel (models .Model ):
91-     choices_field_with_nonstandard_args  =  models .DecimalField (max_digits = 3 , decimal_places = 1 , choices = DECIMAL_CHOICES , verbose_name = 'A label' )
92+     choices_field_with_nonstandard_args  =  models .DecimalField (max_digits = 3 , decimal_places = 1 , choices = DECIMAL_CHOICES ,
93+                                                               verbose_name = 'A label' )
9294
9395
9496class  Issue3674ParentModel (models .Model ):
@@ -133,6 +135,7 @@ def test_abstract_model(self):
133135        Test that trying to use ModelSerializer with Abstract Models 
134136        throws a ValueError exception. 
135137        """ 
138+ 
136139        class  AbstractModel (models .Model ):
137140            afield  =  models .CharField (max_length = 255 )
138141
@@ -158,6 +161,7 @@ def test_regular_fields(self):
158161        """ 
159162        Model fields should map to their equivalent serializer fields. 
160163        """ 
164+ 
161165        class  TestSerializer (serializers .ModelSerializer ):
162166            class  Meta :
163167                model  =  RegularFieldsModel 
@@ -222,6 +226,7 @@ def test_method_field(self):
222226        Properties and methods on the model should be allowed as `Meta.fields` 
223227        values, and should map to `ReadOnlyField`. 
224228        """ 
229+ 
225230        class  TestSerializer (serializers .ModelSerializer ):
226231            class  Meta :
227232                model  =  RegularFieldsModel 
@@ -238,6 +243,7 @@ def test_pk_fields(self):
238243        """ 
239244        Both `pk` and the actual primary key name are valid in `Meta.fields`. 
240245        """ 
246+ 
241247        class  TestSerializer (serializers .ModelSerializer ):
242248            class  Meta :
243249                model  =  RegularFieldsModel 
@@ -254,6 +260,7 @@ def test_extra_field_kwargs(self):
254260        """ 
255261        Ensure `extra_kwargs` are passed to generated fields. 
256262        """ 
263+ 
257264        class  TestSerializer (serializers .ModelSerializer ):
258265            class  Meta :
259266                model  =  RegularFieldsModel 
@@ -271,6 +278,7 @@ def test_extra_field_kwargs_required(self):
271278        """ 
272279        Ensure `extra_kwargs` are passed to generated fields. 
273280        """ 
281+ 
274282        class  TestSerializer (serializers .ModelSerializer ):
275283            class  Meta :
276284                model  =  RegularFieldsModel 
@@ -289,6 +297,7 @@ def test_invalid_field(self):
289297        Field names that do not map to a model field or relationship should 
290298        raise a configuration errror. 
291299        """ 
300+ 
292301        class  TestSerializer (serializers .ModelSerializer ):
293302            class  Meta :
294303                model  =  RegularFieldsModel 
@@ -304,6 +313,7 @@ def test_missing_field(self):
304313        Fields that have been declared on the serializer class must be included 
305314        in the `Meta.fields` if it exists. 
306315        """ 
316+ 
307317        class  TestSerializer (serializers .ModelSerializer ):
308318            missing  =  serializers .ReadOnlyField ()
309319
@@ -324,6 +334,7 @@ def test_missing_superclass_field(self):
324334        Fields that have been declared on a parent of the serializer class may 
325335        be excluded from the `Meta.fields` option. 
326336        """ 
337+ 
327338        class  TestSerializer (serializers .ModelSerializer ):
328339            missing  =  serializers .ReadOnlyField ()
329340
@@ -754,10 +765,10 @@ class Meta:
754765        assert  instance .foreign_key .pk  ==  new_foreign_key .pk 
755766        assert  instance .one_to_one .pk  ==  new_one_to_one .pk 
756767        assert  [
757-             item .pk  for  item  in  instance .many_to_many .all ()
758-         ] ==  [
759-             item .pk  for  item  in  new_many_to_many 
760-         ]
768+                     item .pk  for  item  in  instance .many_to_many .all ()
769+                 ] ==  [
770+                     item .pk  for  item  in  new_many_to_many 
771+                 ]
761772        assert  list (instance .through .all ()) ==  []
762773
763774        # Representation should be correct. 
@@ -802,10 +813,10 @@ class Meta:
802813        assert  instance .foreign_key .pk  ==  new_foreign_key .pk 
803814        assert  instance .one_to_one .pk  ==  new_one_to_one .pk 
804815        assert  [
805-             item .pk  for  item  in  instance .many_to_many .all ()
806-         ] ==  [
807-             item .pk  for  item  in  new_many_to_many 
808-         ]
816+                     item .pk  for  item  in  instance .many_to_many .all ()
817+                 ] ==  [
818+                     item .pk  for  item  in  new_many_to_many 
819+                 ]
809820        assert  list (instance .through .all ()) ==  []
810821
811822        # Representation should be correct. 
@@ -940,6 +951,7 @@ def test_decimal_field_has_decimal_validator(self):
940951        """ 
941952        Test that a `DecimalField` has no `DecimalValidator`. 
942953        """ 
954+ 
943955        class  TestSerializer (serializers .ModelSerializer ):
944956            class  Meta :
945957                model  =  DecimalFieldModel 
@@ -954,6 +966,7 @@ def test_min_value_is_passed(self):
954966        Test that the `MinValueValidator` is converted to the `min_value` 
955967        argument for the field. 
956968        """ 
969+ 
957970        class  TestSerializer (serializers .ModelSerializer ):
958971            class  Meta :
959972                model  =  DecimalFieldModel 
@@ -968,6 +981,7 @@ def test_max_value_is_passed(self):
968981        Test that the `MaxValueValidator` is converted to the `max_value` 
969982        argument for the field. 
970983        """ 
984+ 
971985        class  TestSerializer (serializers .ModelSerializer ):
972986            class  Meta :
973987                model  =  DecimalFieldModel 
@@ -1085,7 +1099,6 @@ class Meta:
10851099        self .assertEqual (unicode_repr (TestChildModelSerializer ()), child_expected )
10861100
10871101    def  test_nonID_PK_foreignkey_model_serializer (self ):
1088- 
10891102        class  TestChildModelSerializer (serializers .ModelSerializer ):
10901103            class  Meta :
10911104                model  =  Issue3674ChildModel 
@@ -1136,18 +1149,20 @@ class Meta:
11361149        assert  not  serializer .is_valid ()
11371150        assert  serializer .errors  ==  {'name' : ['unique choice model with this name already exists.' ]}
11381151
1152+ 
11391153class  Issue5220Model (models .Model ):
11401154    datetime  =  models .DateTimeField ()
11411155
1156+ 
11421157class  Issue5220TestCase (TestCase ):
11431158    def  test_should_raise_error_for_invalid_input (self ):
11441159        class  TestSerializer (serializers .ModelSerializer ):
11451160            class  Meta :
11461161                model  =  Issue5220Model 
11471162                fields  =  ('__all__' )
1163+ 
11481164        serializer  =  TestSerializer (data = {
11491165            'datetime' : '2017-08-16 22:00-24:00' ,
11501166        })
11511167
11521168        assert  not  serializer .is_valid ()
1153- 
0 commit comments