@@ -207,21 +207,32 @@ def test_exc_detail_is_dict_with_non_field_errors_formats(self, mocker, exc_deta
207207 assert data ["invalid_params" ] is None
208208
209209 @pytest .mark .parametrize (
210- "exc_detail" ,
210+ "exc_detail, expected_detail " ,
211211 [
212- "This is a non-field error." ,
213- ["This is a non-field error." ],
212+ ("This is a non-field error." , ["This is a non-field error." ]),
213+ (["This is a non-field error." ], ["This is a non-field error." ]),
214+ (
215+ ["This is a non-field error." , "Another error." ],
216+ ["This is a non-field error." , "Another error." ],
217+ ),
218+ (
219+ [
220+ "This is a non-field error." ,
221+ ["Another error." , "Yet another error." ],
222+ ],
223+ ["This is a non-field error." , "Another error." , "Yet another error." ],
224+ ),
214225 ],
215226 )
216- def test_exc_detail_is_list_formats (self , exc_detail ):
227+ def test_exc_detail_is_list_formats (self , exc_detail , expected_detail ):
217228 """
218229 Test that when the exception detail is a list or a string,
219230 the detail is set to the error messages list and invalid_params is `None`.
220231 """
221232 exc = drf_exceptions .ValidationError (exc_detail )
222233
223234 data = formatter .format_exc (exc )
224- assert data ["detail" ] == [ "This is a non-field error." ]
235+ assert data ["detail" ] == expected_detail
225236 assert data ["invalid_params" ] is None
226237
227238 def test_format_exc_detail_is_list_error_when_unexpected_type (self ):
0 commit comments