fix the exception message when validating unicode URLs
This commit is contained in:
@@ -346,6 +346,25 @@ class FieldTest(MongoDBTestCase):
|
||||
class Link(Document):
|
||||
url = URLField()
|
||||
|
||||
link = Link()
|
||||
link.url = u'http://привет.com'
|
||||
|
||||
# TODO fix URL validation - this IS a valid URL
|
||||
# For now we just want to make sure that the error message is correct
|
||||
try:
|
||||
link.validate()
|
||||
self.assertTrue(False)
|
||||
except ValidationError as e:
|
||||
self.assertEqual(
|
||||
unicode(e),
|
||||
u"ValidationError (Link:None) (Invalid URL: http://\u043f\u0440\u0438\u0432\u0435\u0442.com: ['url'])"
|
||||
)
|
||||
|
||||
def test_unicode_url_validation(self):
|
||||
"""Ensure unicode URLs are validated properly."""
|
||||
class Link(Document):
|
||||
url = URLField()
|
||||
|
||||
link = Link()
|
||||
link.url = 'google'
|
||||
self.assertRaises(ValidationError, link.validate)
|
||||
|
||||
Reference in New Issue
Block a user