Moved the test added in r15504 to a different case where it doesn't actually verify the existence of the URL by calling urlopen but only validates it.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15551 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-02-16 12:50:46 +00:00
parent d5042109b8
commit 24e0b56dcb
1 changed files with 13 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import datetime
import time import time
import re import re
import os import os
import urllib2
from decimal import Decimal from decimal import Decimal
from django.core.files.uploadedfile import SimpleUploadedFile from django.core.files.uploadedfile import SimpleUploadedFile
@ -571,8 +572,6 @@ class FieldsTests(TestCase):
f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
except ValidationError, e: except ValidationError, e:
self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
# UTF-8 char in path
self.assertEqual(u'http://de.wikipedia.org/wiki/T\xfcr', f.clean(u'http://de.wikipedia.org/wiki/T\xfcr'))
def test_urlfield_4(self): def test_urlfield_4(self):
f = URLField(verify_exists=True, required=False) f = URLField(verify_exists=True, required=False)
@ -626,6 +625,18 @@ class FieldsTests(TestCase):
except ValidationError, e: except ValidationError, e:
self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
def test_urlfield_10(self):
# UTF-8 char in path, enclosed by a monkey-patch to make sure
# the encoding is passed to urllib2.urlopen
f = URLField(verify_exists=True)
try:
_orig_urlopen = urllib2.urlopen
urllib2.urlopen = lambda req: True
url = u'http://t\xfcr.djangoproject.com/'
self.assertEqual(url, f.clean(url))
finally:
urllib2.urlopen = _orig_urlopen
# BooleanField ################################################################ # BooleanField ################################################################
def test_booleanfield_1(self): def test_booleanfield_1(self):