mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Issue #21069: Move test_fileno() from test_urllibnet and rewrite it
* No longer attempts to close already freed socket file descriptor * Use socket object to be compatible with Windows * Do not use a timeout to avoid complication with non-blocking mode * Use internal localhost server rather than depending on a third party * Avoid trouble with buffered HTTP data by testing tunnelled CONNECT data
This commit is contained in:
parent
fc475a9fa6
commit
d979b2cfcf
2 changed files with 41 additions and 11 deletions
|
|
@ -99,17 +99,6 @@ class urlopenNetworkTests(unittest.TestCase):
|
|||
open_url.close()
|
||||
self.assertEqual(code, 404)
|
||||
|
||||
# On Windows, socket handles are not file descriptors; this
|
||||
# test can't pass on Windows.
|
||||
@unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows')
|
||||
def test_fileno(self):
|
||||
# Make sure fd returned by fileno is valid.
|
||||
with self.urlopen("http://www.google.com/") as open_url:
|
||||
fd = open_url.fileno()
|
||||
with os.fdopen(fd, 'rb') as f:
|
||||
self.assertTrue(f.read(), "reading from file created using fd "
|
||||
"returned by fileno failed")
|
||||
|
||||
def test_bad_address(self):
|
||||
# Make sure proper exception is raised when connecting to a bogus
|
||||
# address.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue