|
2 | 2 | from test import support |
3 | 3 | from test.support import os_helper |
4 | 4 | from test.support import socket_helper |
| 5 | +from test.support.testcase import ExtraAssertions |
5 | 6 |
|
6 | 7 | import contextlib |
7 | 8 | import socket |
@@ -34,7 +35,7 @@ def testURLread(self): |
34 | 35 | f.read() |
35 | 36 |
|
36 | 37 |
|
37 | | -class urlopenNetworkTests(unittest.TestCase): |
| 38 | +class urlopenNetworkTests(unittest.TestCase, ExtraAssertions): |
38 | 39 | """Tests urllib.request.urlopen using the network. |
39 | 40 |
|
40 | 41 | These tests are not exhaustive. Assuming that testing using files does a |
@@ -70,8 +71,7 @@ def test_basic(self): |
70 | 71 | with self.urlopen(self.url) as open_url: |
71 | 72 | for attr in ("read", "readline", "readlines", "fileno", "close", |
72 | 73 | "info", "geturl"): |
73 | | - self.assertTrue(hasattr(open_url, attr), "object returned from " |
74 | | - "urlopen lacks the %s attribute" % attr) |
| 74 | + self.assertHasAttr(open_url, attr) |
75 | 75 | self.assertTrue(open_url.read(), "calling 'read' failed") |
76 | 76 |
|
77 | 77 | def test_readlines(self): |
@@ -109,6 +109,7 @@ def test_getcode(self): |
109 | 109 | open_url.close() |
110 | 110 | self.assertEqual(code, 404) |
111 | 111 |
|
| 112 | + @support.requires_resource('walltime') |
112 | 113 | def test_bad_address(self): |
113 | 114 | # Make sure proper exception is raised when connecting to a bogus |
114 | 115 | # address. |
@@ -191,6 +192,7 @@ def test_header(self): |
191 | 192 |
|
192 | 193 | logo = "http://www.pythontest.net/" |
193 | 194 |
|
| 195 | + @support.requires_resource('walltime') |
194 | 196 | def test_data_header(self): |
195 | 197 | with self.urlretrieve(self.logo) as (file_location, fileheaders): |
196 | 198 | datevalue = fileheaders.get('Date') |
|
0 commit comments