@@ -43,7 +43,7 @@ def tearDown(self):
4343 socket .setdefaulttimeout (None )
4444
4545 def testURLread (self ):
46- f = _open_with_retry (urllib .urlopen , "http://www.example.com/" )
46+ f = _open_with_retry (urllib .urlopen , test_support . TEST_HTTP_URL )
4747 x = f .read ()
4848
4949class urlopenNetworkTests (unittest .TestCase ):
@@ -66,7 +66,7 @@ def urlopen(self, *args):
6666
6767 def test_basic (self ):
6868 # Simple test expected to pass.
69- open_url = self .urlopen ("http://www.example.com/" )
69+ open_url = self .urlopen (test_support . TEST_HTTP_URL )
7070 for attr in ("read" , "readline" , "readlines" , "fileno" , "close" ,
7171 "info" , "geturl" ):
7272 self .assertTrue (hasattr (open_url , attr ), "object returned from "
@@ -78,7 +78,7 @@ def test_basic(self):
7878
7979 def test_readlines (self ):
8080 # Test both readline and readlines.
81- open_url = self .urlopen ("http://www.example.com/" )
81+ open_url = self .urlopen (test_support . TEST_HTTP_URL )
8282 try :
8383 self .assertIsInstance (open_url .readline (), basestring ,
8484 "readline did not return a string" )
@@ -89,7 +89,7 @@ def test_readlines(self):
8989
9090 def test_info (self ):
9191 # Test 'info'.
92- open_url = self .urlopen ("http://www.example.com/" )
92+ open_url = self .urlopen (test_support . TEST_HTTP_URL )
9393 try :
9494 info_obj = open_url .info ()
9595 finally :
@@ -101,13 +101,12 @@ def test_info(self):
101101
102102 def test_geturl (self ):
103103 # Make sure same URL as opened is returned by geturl.
104- URL = "http://www.example.com/"
105- open_url = self .urlopen (URL )
104+ open_url = self .urlopen (test_support .TEST_HTTP_URL )
106105 try :
107106 gotten_url = open_url .geturl ()
108107 finally :
109108 open_url .close ()
110- self .assertEqual (gotten_url , URL )
109+ self .assertEqual (gotten_url , test_support . TEST_HTTP_URL )
111110
112111 def test_getcode (self ):
113112 # test getcode() with the fancy opener to get 404 error codes
@@ -123,12 +122,13 @@ def test_getcode(self):
123122 @unittest .skipUnless (hasattr (os , 'fdopen' ), 'os.fdopen not available' )
124123 def test_fileno (self ):
125124 # Make sure fd returned by fileno is valid.
126- open_url = self .urlopen ("http://www.example.com/" )
125+ open_url = self .urlopen (test_support . TEST_HTTP_URL )
127126 fd = open_url .fileno ()
128127 FILE = os .fdopen (fd )
129128 try :
130- self .assertTrue (FILE .read (), "reading from file created using fd "
131- "returned by fileno failed" )
129+ self .assertTrue (FILE .read (),
130+ "reading from file created using fd "
131+ "returned by fileno failed" )
132132 finally :
133133 FILE .close ()
134134
@@ -161,7 +161,7 @@ def urlretrieve(self, *args):
161161
162162 def test_basic (self ):
163163 # Test basic functionality.
164- file_location ,info = self .urlretrieve ("http://www.example.com/" )
164+ file_location ,info = self .urlretrieve (test_support . TEST_HTTP_URL )
165165 self .assertTrue (os .path .exists (file_location ), "file location returned by"
166166 " urlretrieve is not a valid path" )
167167 FILE = file (file_location )
@@ -174,7 +174,7 @@ def test_basic(self):
174174
175175 def test_specified_path (self ):
176176 # Make sure that specifying the location of the file to write to works.
177- file_location ,info = self .urlretrieve ("http://www.example.com/" ,
177+ file_location ,info = self .urlretrieve (test_support . TEST_HTTP_URL ,
178178 test_support .TESTFN )
179179 self .assertEqual (file_location , test_support .TESTFN )
180180 self .assertTrue (os .path .exists (file_location ))
@@ -187,13 +187,13 @@ def test_specified_path(self):
187187
188188 def test_header (self ):
189189 # Make sure header returned as 2nd value from urlretrieve is good.
190- file_location , header = self .urlretrieve ("http://www.example.com/" )
190+ file_location , header = self .urlretrieve (test_support . TEST_HTTP_URL )
191191 os .unlink (file_location )
192192 self .assertIsInstance (header , mimetools .Message ,
193193 "header is not an instance of mimetools.Message" )
194194
195195 def test_data_header (self ):
196- logo = "http://www.example.com/"
196+ logo = test_support . TEST_HTTP_URL
197197 file_location , fileheaders = self .urlretrieve (logo )
198198 os .unlink (file_location )
199199 datevalue = fileheaders .getheader ('Date' )
0 commit comments