diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
index dd42936..6c5f1e3 100644
a
|
b
|
class ModelToValidate(models.Model):
|
16 | 16 | email = models.EmailField(blank=True) |
17 | 17 | url = models.URLField(blank=True) |
18 | 18 | f_with_custom_validator = models.IntegerField(blank=True, null=True, validators=[validate_answer_to_universe]) |
19 | | |
20 | 19 | def clean(self): |
21 | 20 | super(ModelToValidate, self).clean() |
22 | 21 | if self.number == 11: |
23 | 22 | raise ValidationError('Invalid number supplied!') |
24 | 23 | |
| 24 | class ModelWithNonBlank(models.Model): |
| 25 | f_non_blank = models.IntegerField(blank=False) |
| 26 | def clean(self): |
| 27 | super(ModelWithNonBlank, self).clean() |
| 28 | if not self.f_non_blank: |
| 29 | self.f_non_blank = 12 |
| 30 | |
25 | 31 | class UniqueFieldsModel(models.Model): |
26 | 32 | unique_charfield = models.CharField(max_length=100, unique=True) |
27 | 33 | unique_integerfield = models.IntegerField(unique=True) |
diff --git a/tests/modeltests/validation/tests.py b/tests/modeltests/validation/tests.py
index 0027393..23f2404 100644
a
|
b
|
from django import forms
|
2 | 2 | from django.test import TestCase |
3 | 3 | from django.core.exceptions import NON_FIELD_ERRORS |
4 | 4 | from modeltests.validation import ValidationTestCase |
5 | | from modeltests.validation.models import Author, Article, ModelToValidate |
| 5 | from modeltests.validation.models import Author, Article, ModelToValidate, ModelWithNonBlank |
6 | 6 | |
7 | 7 | # Import other tests for this package. |
8 | 8 | from modeltests.validation.validators import TestModelsWithValidators |
… |
… |
class BaseModelValidationTests(ValidationTestCase):
|
64 | 64 | mtv = ModelToValidate(number=10, name='Some Name'*100) |
65 | 65 | self.assertFailsValidation(mtv.full_clean, ['name',]) |
66 | 66 | |
| 67 | def test_blank_passes(self): |
| 68 | mwnb = ModelWithNonBlank() |
| 69 | self.assertEqual(None, mwnb.full_clean()) |
| 70 | |
67 | 71 | class ArticleForm(forms.ModelForm): |
68 | 72 | class Meta: |
69 | 73 | model = Article |