diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/socket.py | 6 | ||||
-rw-r--r-- | Lib/test/test_urllibnet.py | 32 |
2 files changed, 33 insertions, 5 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index a8a4e39d5a..cb0181b2a6 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -59,13 +59,10 @@ if _have_ssl: __all__.extend(os._get_exports_list(_ssl)) _realsocket = socket -_needwrapper = False if (sys.platform.lower().startswith("win") or (hasattr(os, 'uname') and os.uname()[0] == "BeOS") or sys.platform=="riscos"): - _needwrapper = True - if _have_ssl: _realssl = ssl def ssl(sock, keyfile=None, certfile=None): @@ -180,8 +177,7 @@ class _socketobject(object): exec _s % (_m, _m, _m, _m) del _m, _s -if _needwrapper: - socket = SocketType = _socketobject +socket = SocketType = _socketobject class _fileobject(object): """Faux file object attached to a socket object.""" diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py new file mode 100644 index 0000000000..3af2491ecc --- /dev/null +++ b/Lib/test/test_urllibnet.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import unittest +from test import test_support + +import socket +import urllib2 +import sys + +class URLTimeoutTest(unittest.TestCase): + + TIMEOUT = 10.0 + + def setUp(self): + socket.setdefaulttimeout(self.TIMEOUT) + + def tearDown(self): + socket.setdefaulttimeout(None) + + def testURLread(self): + f = urllib2.urlopen("http://www.python.org/") + x = f.read() + +def test_main(): + test_support.requires('network') + + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(URLTimeoutTest)) + test_support.run_suite(suite) + +if __name__ == "__main__": + test_main() |