MCPcopy
hub / github.com/django/django / test_clean_false_required

Method test_clean_false_required

tests/model_forms/tests.py:2504–2513  ·  view source on GitHub ↗

If the ``clean`` method on a required FileField receives False as the data, it has the same effect as None: initial is returned if non-empty, otherwise the validation catches the lack of a required value.

(self)

Source from the content-addressed store, hash-verified

2502 self.assertIs(f.clean(False, "initial"), False)
2503
2504 def test_clean_false_required(self):
2505 """
2506 If the ``clean`` method on a required FileField receives False as the
2507 data, it has the same effect as None: initial is returned if non-empty,
2508 otherwise the validation catches the lack of a required value.
2509 """
2510 f = forms.FileField(required=True)
2511 self.assertEqual(f.clean(False, "initial"), "initial")
2512 with self.assertRaises(ValidationError):
2513 f.clean(False)
2514
2515 def test_full_clear(self):
2516 """

Callers

nothing calls this directly

Calls 1

cleanMethod · 0.95

Tested by

no test coverage detected