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

[py3] Updated urllib/urllib2/urlparse imports.

Lots of functions were moved. Use explicit imports in all cases
to keey it easy to identify where the functions come from.
This commit is contained in:
Aymeric Augustin
2012-07-20 15:36:52 +02:00
parent bdca5ea345
commit 0d914d08a0
32 changed files with 181 additions and 96 deletions

View File

@@ -2,7 +2,10 @@
Tests for django.core.servers.
"""
import os
import urllib2
try:
from urllib.request import urlopen, HTTPError
except ImportError: # Python 2
from urllib2 import urlopen, HTTPError
from django.core.exceptions import ImproperlyConfigured
from django.test import LiveServerTestCase
@@ -39,7 +42,7 @@ class LiveServerBase(LiveServerTestCase):
super(LiveServerBase, cls).tearDownClass()
def urlopen(self, url):
return urllib2.urlopen(self.live_server_url + url)
return urlopen(self.live_server_url + url)
class LiveServerAddress(LiveServerBase):
@@ -102,7 +105,7 @@ class LiveServerViews(LiveServerBase):
"""
try:
self.urlopen('/')
except urllib2.HTTPError as err:
except HTTPError as err:
self.assertEqual(err.code, 404, 'Expected 404 response')
else:
self.fail('Expected 404 response')