summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllibnet.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2008-06-18 20:49:58 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2008-06-18 20:49:58 (GMT)
commit1afc1696167547a5fa101c53e5a3ab4717f8852c (patch)
treee989e72e71530d892214562785df7e11f84c1111 /Lib/test/test_urllibnet.py
parenta656d2cd8984f1ecb5a7e2cd09a18f72452f2b78 (diff)
downloadcpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.zip
cpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.tar.gz
cpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.tar.bz2
Make a new urllib package .
It consists of code from urllib, urllib2, urlparse, and robotparser. The old modules have all been removed. The new package has five submodules: urllib.parse, urllib.request, urllib.response, urllib.error, and urllib.robotparser. The urllib.request.urlopen() function uses the url opener from urllib2. Note that the unittests have not been renamed for the beta, but they will be renamed in the future. Joint work with Senthil Kumaran.
Diffstat (limited to 'Lib/test/test_urllibnet.py')
-rw-r--r--Lib/test/test_urllibnet.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index d4831d8..c8166c4 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -4,7 +4,7 @@ import unittest
from test import support
import socket
-import urllib
+import urllib.request
import sys
import os
import email.message
@@ -36,11 +36,11 @@ class URLTimeoutTest(unittest.TestCase):
socket.setdefaulttimeout(None)
def testURLread(self):
- f = _open_with_retry(urllib.urlopen, "http://www.python.org/")
+ f = _open_with_retry(urllib.request.urlopen, "http://www.python.org/")
x = f.read()
class urlopenNetworkTests(unittest.TestCase):
- """Tests urllib.urlopen using the network.
+ """Tests urllib.reqest.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no
@@ -55,7 +55,7 @@ class urlopenNetworkTests(unittest.TestCase):
"""
def urlopen(self, *args):
- return _open_with_retry(urllib.urlopen, *args)
+ return _open_with_retry(urllib.request.urlopen, *args)
def test_basic(self):
# Simple test expected to pass.
@@ -105,7 +105,7 @@ class urlopenNetworkTests(unittest.TestCase):
def test_getcode(self):
# test getcode() with the fancy opener to get 404 error codes
URL = "http://www.python.org/XXXinvalidXXX"
- open_url = urllib.FancyURLopener().open(URL)
+ open_url = urllib.request.FancyURLopener().open(URL)
try:
code = open_url.getcode()
finally:
@@ -114,7 +114,7 @@ class urlopenNetworkTests(unittest.TestCase):
def test_fileno(self):
if (sys.platform in ('win32',) or
- not hasattr(os, 'fdopen')):
+ not hasattr(os, 'fdopen')):
# On Windows, socket handles are not file descriptors; this
# test can't pass on Windows.
return
@@ -142,13 +142,14 @@ class urlopenNetworkTests(unittest.TestCase):
# domain will be spared to serve its defined
# purpose.
# urllib.urlopen, "http://www.sadflkjsasadf.com/")
- urllib.urlopen, "http://www.python.invalid./")
+ urllib.request.urlopen,
+ "http://www.python.invalid./")
class urlretrieveNetworkTests(unittest.TestCase):
- """Tests urllib.urlretrieve using the network."""
+ """Tests urllib.request.urlretrieve using the network."""
def urlretrieve(self, *args):
- return _open_with_retry(urllib.urlretrieve, *args)
+ return _open_with_retry(urllib.request.urlretrieve, *args)
def test_basic(self):
# Test basic functionality.