1
0
mirror of https://github.com/django/django.git synced 2024-11-18 07:26:04 +00:00
django/tests/validation/__init__.py
Tim Graham 1dae4ac177 Whitespace cleanup.
* Removed trailing whitespace.
* Added newline to EOF if missing.
* Removed blank lines at EOF.
* Removed some stray tabs.
2013-10-10 16:49:20 -04:00

16 lines
630 B
Python

from django.core.exceptions import ValidationError
from django.test import TestCase
class ValidationTestCase(TestCase):
def assertFailsValidation(self, clean, failed_fields):
with self.assertRaises(ValidationError) as cm:
clean()
self.assertEqual(sorted(failed_fields), sorted(cm.exception.message_dict))
def assertFieldFailsValidationWithMessage(self, clean, field_name, message):
with self.assertRaises(ValidationError) as cm:
clean()
self.assertIn(field_name, cm.exception.message_dict)
self.assertEqual(message, cm.exception.message_dict[field_name])