Commit 813cec9a authored by Tim Peters's avatar Tim Peters

test_fileno(): Skip this test on Windows.

parent 047c54bb
...@@ -25,17 +25,17 @@ class URLTimeoutTest(unittest.TestCase): ...@@ -25,17 +25,17 @@ class URLTimeoutTest(unittest.TestCase):
class urlopenNetworkTests(unittest.TestCase): class urlopenNetworkTests(unittest.TestCase):
"""Tests urllib.urlopen using the network. """Tests urllib.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no good job overall of some of the basic interface features. There are no
tests exercising the optional 'data' and 'proxies' arguments. No tests tests exercising the optional 'data' and 'proxies' arguments. No tests
for transparent redirection have been written. for transparent redirection have been written.
setUp is not used for always constructing a connection to setUp is not used for always constructing a connection to
http://www.python.org/ since there a few tests that don't use that address http://www.python.org/ since there a few tests that don't use that address
and making a connection is expensive enough to warrant minimizing unneeded and making a connection is expensive enough to warrant minimizing unneeded
connections. connections.
""" """
def test_basic(self): def test_basic(self):
...@@ -84,16 +84,20 @@ class urlopenNetworkTests(unittest.TestCase): ...@@ -84,16 +84,20 @@ class urlopenNetworkTests(unittest.TestCase):
self.assertEqual(gotten_url, URL) self.assertEqual(gotten_url, URL)
def test_fileno(self): def test_fileno(self):
if (sys.platform in ('win32',) or
not hasattr(os, 'fdopen')):
# On Windows, socket handles are not file descriptors; this
# test can't pass on Windows.
return
# Make sure fd returned by fileno is valid. # Make sure fd returned by fileno is valid.
if hasattr(os, 'fdopen'): open_url = urllib.urlopen("http://www.python.org/")
open_url = urllib.urlopen("http://www.python.org/") fd = open_url.fileno()
fd = open_url.fileno() FILE = os.fdopen(fd)
FILE = os.fdopen(fd) try:
try: self.assert_(FILE.read(), "reading from file created using fd "
self.assert_(FILE.read(), "reading from file created using fd " "returned by fileno failed")
"returned by fileno failed") finally:
finally: FILE.close()
FILE.close()
def test_bad_address(self): def test_bad_address(self):
# Make sure proper exception is raised when connecting to a bogus # Make sure proper exception is raised when connecting to a bogus
...@@ -136,7 +140,7 @@ class urlretrieveNetworkTests(unittest.TestCase): ...@@ -136,7 +140,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
os.unlink(file_location) os.unlink(file_location)
self.assert_(isinstance(header, mimetools.Message), self.assert_(isinstance(header, mimetools.Message),
"header is not an instance of mimetools.Message") "header is not an instance of mimetools.Message")
def test_main(): def test_main():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment