mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update test_urllibnet.py from 3.13.11 (#6432)
This commit is contained in:
8
Lib/test/test_urllibnet.py
vendored
8
Lib/test/test_urllibnet.py
vendored
@@ -2,6 +2,7 @@ import unittest
|
||||
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
|
||||
@@ -34,7 +35,7 @@ class URLTimeoutTest(unittest.TestCase):
|
||||
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
|
||||
@@ -70,8 +71,7 @@ class urlopenNetworkTests(unittest.TestCase):
|
||||
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):
|
||||
@@ -109,6 +109,7 @@ class urlopenNetworkTests(unittest.TestCase):
|
||||
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.
|
||||
@@ -191,6 +192,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
|
||||
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user