diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index d37ad5e..f815c77 100644
a
|
b
|
def verify_exists_urls(existing_urls=()):
|
53 | 53 | @wraps(func) |
54 | 54 | def wrapper(*args, **kwargs): |
55 | 55 | from django.core import validators |
56 | | # patch urllib2 |
57 | | original_urlopen = validators.urllib2.urlopen |
58 | | def urlopen(req): |
59 | | url = req.get_full_url() |
60 | | if url in existing_urls: |
| 56 | # patch urllib2.OpenerDirector |
| 57 | original_open = validators.urllib2.OpenerDirector.open |
| 58 | def custom_open(self, req, data=None): |
| 59 | if req.get_full_url() in existing_urls: |
61 | 60 | return True |
62 | 61 | raise Exception() |
63 | 62 | try: |
64 | | urllib2.urlopen = urlopen |
| 63 | urllib2.OpenerDirector.open = custom_open |
65 | 64 | func(*args, **kwargs) |
66 | 65 | finally: |
67 | | # unpatch urllib2 |
68 | | validators.urllib2.urlopen = original_urlopen |
| 66 | # unpatch urllib2.OpenerDirector |
| 67 | validators.urllib2.OpenerDirector.open = original_open |
69 | 68 | return wrapper |
70 | 69 | return decorator |
71 | 70 | |
… |
… |
class FieldsTests(SimpleTestCase):
|
690 | 689 | except ValidationError, e: |
691 | 690 | self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) |
692 | 691 | |
| 692 | @verify_exists_urls((u'http://xn--hxargifdar.idn.icann.org/%CE%91%CF%81%CF%87%CE%B9%CE%BA%CE%AE_%CF%83%CE%B5%CE%BB%CE%AF%CE%B4%CE%B1',)) |
693 | 693 | def test_urlfield_10(self): |
694 | | # UTF-8 in the domain. |
| 694 | # UTF-8 in the domain. |
695 | 695 | f = URLField(verify_exists=True) |
696 | 696 | url = u'http://\u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac.idn.icann.org/\u0391\u03c1\u03c7\u03b9\u03ba\u03ae_\u03c3\u03b5\u03bb\u03af\u03b4\u03b1' |
697 | 697 | self.assertEqual(url, f.clean(url)) |