@@ -24,8 +24,8 @@ def tearDown(self):
24
24
socket .setdefaulttimeout (None )
25
25
26
26
def testURLread (self ):
27
- with support .transient_internet ("www.python.org " ):
28
- f = urllib .request .urlopen ("http://www.python.org /" )
27
+ with support .transient_internet ("www.example.com " ):
28
+ f = urllib .request .urlopen ("http://www.example.com /" )
29
29
x = f .read ()
30
30
31
31
@@ -38,7 +38,7 @@ class urlopenNetworkTests(unittest.TestCase):
38
38
for transparent redirection have been written.
39
39
40
40
setUp is not used for always constructing a connection to
41
- http://www.python.org / since there a few tests that don't use that address
41
+ http://www.example.com / since there a few tests that don't use that address
42
42
and making a connection is expensive enough to warrant minimizing unneeded
43
43
connections.
44
44
@@ -56,7 +56,7 @@ def urlopen(self, *args, **kwargs):
56
56
57
57
def test_basic (self ):
58
58
# Simple test expected to pass.
59
- with self .urlopen ("http://www.python.org /" ) as open_url :
59
+ with self .urlopen ("http://www.example.com /" ) as open_url :
60
60
for attr in ("read" , "readline" , "readlines" , "fileno" , "close" ,
61
61
"info" , "geturl" ):
62
62
self .assertTrue (hasattr (open_url , attr ), "object returned from "
@@ -65,15 +65,15 @@ def test_basic(self):
65
65
66
66
def test_readlines (self ):
67
67
# Test both readline and readlines.
68
- with self .urlopen ("http://www.python.org /" ) as open_url :
68
+ with self .urlopen ("http://www.example.com /" ) as open_url :
69
69
self .assertIsInstance (open_url .readline (), bytes ,
70
70
"readline did not return a string" )
71
71
self .assertIsInstance (open_url .readlines (), list ,
72
72
"readlines did not return a list" )
73
73
74
74
def test_info (self ):
75
75
# Test 'info'.
76
- with self .urlopen ("http://www.python.org /" ) as open_url :
76
+ with self .urlopen ("http://www.example.com /" ) as open_url :
77
77
info_obj = open_url .info ()
78
78
self .assertIsInstance (info_obj , email .message .Message ,
79
79
"object returned by 'info' is not an "
@@ -82,14 +82,14 @@ def test_info(self):
82
82
83
83
def test_geturl (self ):
84
84
# Make sure same URL as opened is returned by geturl.
85
- URL = "http://www.python.org /"
85
+ URL = "http://www.example.com /"
86
86
with self .urlopen (URL ) as open_url :
87
87
gotten_url = open_url .geturl ()
88
88
self .assertEqual (gotten_url , URL )
89
89
90
90
def test_getcode (self ):
91
91
# test getcode() with the fancy opener to get 404 error codes
92
- URL = "http://www.python.org /XXXinvalidXXX"
92
+ URL = "http://www.example.com /XXXinvalidXXX"
93
93
with support .transient_internet (URL ):
94
94
open_url = urllib .request .FancyURLopener ().open (URL )
95
95
try :
@@ -104,7 +104,7 @@ def test_fileno(self):
104
104
# test can't pass on Windows.
105
105
return
106
106
# Make sure fd returned by fileno is valid.
107
- with self .urlopen ("http://www.python.org /" , timeout = None ) as open_url :
107
+ with self .urlopen ("http://www.example.com /" , timeout = None ) as open_url :
108
108
fd = open_url .fileno ()
109
109
with os .fdopen (fd , 'rb' ) as f :
110
110
self .assertTrue (f .read (), "reading from file created using fd "
@@ -148,7 +148,7 @@ def urlretrieve(self, *args):
148
148
149
149
def test_basic (self ):
150
150
# Test basic functionality.
151
- with self .urlretrieve ("http://www.python.org /" ) as (file_location , info ):
151
+ with self .urlretrieve ("http://www.example.com /" ) as (file_location , info ):
152
152
self .assertTrue (os .path .exists (file_location ), "file location returned by"
153
153
" urlretrieve is not a valid path" )
154
154
with open (file_location , 'rb' ) as f :
@@ -157,7 +157,7 @@ def test_basic(self):
157
157
158
158
def test_specified_path (self ):
159
159
# Make sure that specifying the location of the file to write to works.
160
- with self .urlretrieve ("http://www.python.org /" ,
160
+ with self .urlretrieve ("http://www.example.com /" ,
161
161
support .TESTFN ) as (file_location , info ):
162
162
self .assertEqual (file_location , support .TESTFN )
163
163
self .assertTrue (os .path .exists (file_location ))
@@ -166,12 +166,12 @@ def test_specified_path(self):
166
166
167
167
def test_header (self ):
168
168
# Make sure header returned as 2nd value from urlretrieve is good.
169
- with self .urlretrieve ("http://www.python.org /" ) as (file_location , info ):
169
+ with self .urlretrieve ("http://www.example.com /" ) as (file_location , info ):
170
170
self .assertIsInstance (info , email .message .Message ,
171
171
"info is not an instance of email.message.Message" )
172
172
173
173
def test_data_header (self ):
174
- logo = "http://www.python.org/static/community_logos/python-logo-master-v3-TM.png "
174
+ logo = "http://www.example.com/ "
175
175
with self .urlretrieve (logo ) as (file_location , fileheaders ):
176
176
datevalue = fileheaders .get ('Date' )
177
177
dateformat = '%a, %d %b %Y %H:%M:%S GMT'
0 commit comments