1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #13352 -- Added __repr__ method for Validation Error. Thanks to elpaso66 for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12976 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2010-04-15 11:19:59 +00:00
parent 1cec641669
commit d9aaad4e36
2 changed files with 19 additions and 1 deletions

View File

@@ -137,7 +137,20 @@ def create_simple_test_method(validator, expected, value, num):
# Dynamically assemble a test class with the contents of TEST_DATA
class TestSimpleValidators(TestCase):
pass
def test_single_message(self):
v = ValidationError('Not Valid')
self.assertEquals(str(v), "[u'Not Valid']")
self.assertEquals(repr(v), "ValidationError([u'Not Valid'])")
def test_message_list(self):
v = ValidationError(['First Problem', 'Second Problem'])
self.assertEquals(str(v), "[u'First Problem', u'Second Problem']")
self.assertEquals(repr(v), "ValidationError([u'First Problem', u'Second Problem'])")
def test_message_dict(self):
v = ValidationError({'first': 'First Problem'})
self.assertEquals(str(v), "{'first': 'First Problem'}")
self.assertEquals(repr(v), "ValidationError({'first': 'First Problem'})")
test_counter = 0
for validator, value, expected in TEST_DATA: