From e8446be5600a8f5022e82541df432268ae5f737d Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Sat, 6 Apr 2013 14:01:32 -0500 Subject: Modified validation to work with unittest2 discovery. --- tests/validation/test_validators.py | 19 +++++++++++++++++++ tests/validation/tests.py | 2 +- tests/validation/validators.py | 19 ------------------- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 tests/validation/test_validators.py delete mode 100644 tests/validation/validators.py diff --git a/tests/validation/test_validators.py b/tests/validation/test_validators.py new file mode 100644 index 0000000000..e58d9fd4a6 --- /dev/null +++ b/tests/validation/test_validators.py @@ -0,0 +1,19 @@ +from __future__ import absolute_import, unicode_literals + +from . import ValidationTestCase +from .models import ModelToValidate + + +class TestModelsWithValidators(ValidationTestCase): + def test_custom_validator_passes_for_correct_value(self): + mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42) + self.assertEqual(None, mtv.full_clean()) + + def test_custom_validator_raises_error_for_incorrect_value(self): + mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12) + self.assertFailsValidation(mtv.full_clean, ['f_with_custom_validator']) + self.assertFieldFailsValidationWithMessage( + mtv.full_clean, + 'f_with_custom_validator', + ['This is not the answer to life, universe and everything!'] + ) diff --git a/tests/validation/tests.py b/tests/validation/tests.py index ed9ca96bc6..ead1b57981 100644 --- a/tests/validation/tests.py +++ b/tests/validation/tests.py @@ -12,7 +12,7 @@ from .models import (Author, Article, ModelToValidate, from .test_custom_messages import CustomMessagesTest from .test_error_messages import ValidationMessagesTest from .test_unique import GetUniqueCheckTests, PerformUniqueChecksTest -from .validators import TestModelsWithValidators +from .test_validators import TestModelsWithValidators class BaseModelValidationTests(ValidationTestCase): diff --git a/tests/validation/validators.py b/tests/validation/validators.py deleted file mode 100644 index e58d9fd4a6..0000000000 --- a/tests/validation/validators.py +++ /dev/null @@ -1,19 +0,0 @@ -from __future__ import absolute_import, unicode_literals - -from . import ValidationTestCase -from .models import ModelToValidate - - -class TestModelsWithValidators(ValidationTestCase): - def test_custom_validator_passes_for_correct_value(self): - mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42) - self.assertEqual(None, mtv.full_clean()) - - def test_custom_validator_raises_error_for_incorrect_value(self): - mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12) - self.assertFailsValidation(mtv.full_clean, ['f_with_custom_validator']) - self.assertFieldFailsValidationWithMessage( - mtv.full_clean, - 'f_with_custom_validator', - ['This is not the answer to life, universe and everything!'] - ) -- cgit v1.3