@@ -117,44 +117,32 @@ def test_min_length_singular(self):
117117
118118    def  test_size_length (self ):
119119        field  =  SimpleArrayField (forms .CharField (max_length = 27 ), length = 4 )
120-         with  self .assertRaises (exceptions .ValidationError ) as  cm :
120+         msg  =  "List contains 3 items, it should contain 4." 
121+         with  self .assertRaisesMessage (exceptions .ValidationError , msg ):
121122            field .clean (["a" , "b" , "c" ])
122-         self .assertEqual (
123-             cm .exception .messages [0 ],
124-             "List contains 3 items, it should contain 4." ,
125-         )
126-         with  self .assertRaises (exceptions .ValidationError ) as  cm :
123+         msg  =  "List contains 5 items, it should contain 4." 
124+         with  self .assertRaisesMessage (exceptions .ValidationError , msg ):
127125            field .clean (["a" , "b" , "c" , "d" , "e" ])
128-         self .assertEqual (
129-             cm .exception .messages [0 ],
130-             "List contains 5 items, it should contain 4." ,
131-         )
132126
133127    def  test_size_length_singular (self ):
134128        field  =  SimpleArrayField (forms .CharField (max_length = 27 ), length = 4 )
135-         with  self .assertRaises (exceptions .ValidationError ) as  cm :
129+         msg  =  "List contains 1 item, it should contain 4." 
130+         with  self .assertRaisesMessage (exceptions .ValidationError , msg ):
136131            field .clean (["a" ])
137-         self .assertEqual (
138-             cm .exception .messages [0 ],
139-             "List contains 1 item, it should contain 4." ,
140-         )
141132
142133    def  test_required (self ):
143134        field  =  SimpleArrayField (forms .CharField (), required = True )
144135        with  self .assertRaises (exceptions .ValidationError ) as  cm :
145136            field .clean ("" )
146137        self .assertEqual (cm .exception .messages [0 ], "This field is required." )
147138
148-     def  test_misconfigured (self ):
149-         msg  =  (
150-             "SimpleArrayField param 'length' cannot be specified with 'max_length' or 'min_length'." 
151-         )
152-         with  self .assertRaises (exceptions .ImproperlyConfigured ) as  cm :
139+     def  test_length_and_max_min_length (self ):
140+         msg  =  "The length and max_length parameters are mutually exclusive." 
141+         with  self .assertRaisesMessage (exceptions .ImproperlyConfigured , msg ):
153142            SimpleArrayField (forms .CharField (), max_length = 3 , length = 2 )
154-         self . assertEqual ( cm . exception . args [ 0 ],  msg ) 
155-         with  self .assertRaises (exceptions .ImproperlyConfigured )  as   cm :
143+         msg   =   "The length and min_length parameters are mutually exclusive." 
144+         with  self .assertRaisesMessage (exceptions .ImproperlyConfigured ,  msg ) :
156145            SimpleArrayField (forms .CharField (), min_length = 3 , length = 2 )
157-         self .assertEqual (cm .exception .args [0 ], msg )
158146
159147    def  test_model_field_formfield (self ):
160148        model_field  =  ArrayField (models .CharField (max_length = 27 ))
0 commit comments