@@ -803,12 +803,9 @@ def test_blank_true(self):
803
803
def test_with_max_size (self ):
804
804
field = ArrayField (models .IntegerField (), max_size = 3 )
805
805
field .clean ([1 , 2 , 3 ], None )
806
- with self .assertRaises (exceptions .ValidationError ) as cm :
806
+ msg = "List contains 4 items, it should contain no more than 3."
807
+ with self .assertRaisesMessage (exceptions .ValidationError , msg ):
807
808
field .clean ([1 , 2 , 3 , 4 ], None )
808
- self .assertEqual (
809
- cm .exception .messages [0 ],
810
- "List contains 4 items, it should contain no more than 3." ,
811
- )
812
809
813
810
def test_with_max_size_singular (self ):
814
811
field = ArrayField (models .IntegerField (), max_size = 1 )
@@ -820,12 +817,9 @@ def test_with_max_size_singular(self):
820
817
def test_with_size (self ):
821
818
field = ArrayField (models .IntegerField (), size = 3 )
822
819
field .clean ([1 , 2 , 3 ], None )
823
- with self .assertRaises (exceptions .ValidationError ) as cm :
820
+ msg = "List contains 4 items, it should contain 3."
821
+ with self .assertRaisesMessage (exceptions .ValidationError , msg ):
824
822
field .clean ([1 , 2 , 3 , 4 ], None )
825
- self .assertEqual (
826
- cm .exception .messages [0 ],
827
- "List contains 4 items, it should contain 3." ,
828
- )
829
823
830
824
def test_with_size_singular (self ):
831
825
field = ArrayField (models .IntegerField (), size = 2 )
0 commit comments