1 from __future__
import absolute_import
3 from . import ValidationTestCase
4 from .models
import ModelToValidate
7 class TestModelsWithValidators(ValidationTestCase
):
8 def test_custom_validator_passes_for_correct_value(self
):
9 mtv
= ModelToValidate(number
=10, name
='Some Name', f_with_custom_validator
=42)
10 self
.assertEqual(None, mtv
.full_clean())
12 def test_custom_validator_raises_error_for_incorrect_value(self
):
13 mtv
= ModelToValidate(number
=10, name
='Some Name', f_with_custom_validator
=12)
14 self
.assertFailsValidation(mtv
.full_clean
, ['f_with_custom_validator'])
15 self
.assertFieldFailsValidationWithMessage(
17 'f_with_custom_validator',
18 [u
'This is not the answer to life, universe and everything!']