mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	git-svn-id: http://code.djangoproject.com/svn/django/trunk@17828 bcc190cf-cafb-0310-a4f2-bffc1f526a37
		
			
				
	
	
		
			17 lines
		
	
	
		
			631 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			631 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])
 | |
| 
 |