Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Moved the test added in r15511 to a different test where it d…

…oesn't actually verify the existence of the URL by calling urlopen but only validates it.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15542 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 551da285db768364e9111e6ad0ec368b63bb8377 1 parent fe21117
Jannis Leidel authored February 15, 2011
15  tests/regressiontests/forms/tests/fields.py
@@ -28,6 +28,7 @@
28 28
 import time
29 29
 import re
30 30
 import os
  31
+import urllib2
31 32
 from decimal import Decimal
32 33
 
33 34
 from unittest import TestCase
@@ -567,8 +568,6 @@ def test_urlfield_3(self):
567 568
             f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
568 569
         except ValidationError, e:
569 570
             self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
570  
-        # UTF-8 char in path
571  
-        self.assertEqual(u'http://de.wikipedia.org/wiki/T\xfcr', f.clean(u'http://de.wikipedia.org/wiki/T\xfcr'))
572 571
 
573 572
     def test_urlfield_4(self):
574 573
         f = URLField(verify_exists=True, required=False)
@@ -622,6 +621,18 @@ def test_urlfield_9(self):
622 621
         except ValidationError, e:
623 622
             self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
624 623
 
  624
+    def test_urlfield_10(self):
  625
+        # UTF-8 char in path, enclosed by a monkey-patch to make sure it
  626
+        # the encoding is passed to urllib2.urlopen
  627
+        f = URLField(verify_exists=True)
  628
+        try:
  629
+            _orig_urlopen = urllib2.urlopen
  630
+            urllib2.urlopen = lambda req: True
  631
+            url = u'http://t\xfcr.djangoproject.com/'
  632
+            self.assertEqual(url, f.clean(url))
  633
+        finally:
  634
+            urllib2.urlopen = _orig_urlopen
  635
+
625 636
     # BooleanField ################################################################
626 637
 
627 638
     def test_booleanfield_1(self):

0 notes on commit 551da28

Please sign in to comment.
Something went wrong with that request. Please try again.