MCPcopy
hub / github.com/django/django / test_error_list

Method test_error_list

tests/forms_tests/tests/test_forms.py:4482–4502  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4480 self.assertEqual(errors, control)
4481
4482 def test_error_list(self):
4483 e = ErrorList()
4484 e.append("Foo")
4485 e.append(ValidationError("Foo%(bar)s", code="foobar", params={"bar": "bar"}))
4486
4487 self.assertIsInstance(e, list)
4488 self.assertIn("Foo", e)
4489 self.assertIn("Foo", ValidationError(e))
4490
4491 self.assertEqual(e.as_text(), "* Foo\n* Foobar")
4492
4493 self.assertEqual(
4494 e.as_ul(), '<ul class="errorlist"><li>Foo</li><li>Foobar</li></ul>'
4495 )
4496
4497 errors = e.get_json_data()
4498 self.assertEqual(
4499 errors,
4500 [{"message": "Foo", "code": ""}, {"message": "Foobar", "code": "foobar"}],
4501 )
4502 self.assertEqual(json.dumps(errors), e.as_json())
4503
4504 def test_error_list_class_not_specified(self):
4505 e = ErrorList()

Callers

nothing calls this directly

Calls 8

get_json_dataMethod · 0.95
ErrorListClass · 0.90
ValidationErrorClass · 0.85
as_jsonMethod · 0.80
appendMethod · 0.45
as_textMethod · 0.45
as_ulMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected