Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Lib/test/test_urllibnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from test import support
from test.support import os_helper
from test.support import socket_helper
from test.support.testcase import ExtraAssertions

import contextlib
import socket
Expand Down Expand Up @@ -34,7 +35,7 @@ def testURLread(self):
f.read()


class urlopenNetworkTests(unittest.TestCase):
class urlopenNetworkTests(unittest.TestCase, ExtraAssertions):
"""Tests urllib.request.urlopen using the network.

These tests are not exhaustive. Assuming that testing using files does a
Expand Down Expand Up @@ -70,8 +71,7 @@ def test_basic(self):
with self.urlopen(self.url) as open_url:
for attr in ("read", "readline", "readlines", "fileno", "close",
"info", "geturl"):
self.assertTrue(hasattr(open_url, attr), "object returned from "
"urlopen lacks the %s attribute" % attr)
self.assertHasAttr(open_url, attr)
self.assertTrue(open_url.read(), "calling 'read' failed")

def test_readlines(self):
Expand Down Expand Up @@ -109,6 +109,7 @@ def test_getcode(self):
open_url.close()
self.assertEqual(code, 404)

@support.requires_resource('walltime')
def test_bad_address(self):
# Make sure proper exception is raised when connecting to a bogus
# address.
Expand Down Expand Up @@ -191,6 +192,7 @@ def test_header(self):

logo = "http://www.pythontest.net/"

@support.requires_resource('walltime')
def test_data_header(self):
with self.urlretrieve(self.logo) as (file_location, fileheaders):
datevalue = fileheaders.get('Date')
Expand Down
Loading