summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-03-30 04:54:24 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-03-30 04:54:24 (GMT)
commit89feabc7f5308e3190909f47fce225df28a65062 (patch)
treead1126c669f70a2138f8449453426d298d439a3c /Lib/test
parenta942b9931c9ef13f7baf82c12e4ee312e6906f1c (diff)
downloadcpython-89feabc7f5308e3190909f47fce225df28a65062.zip
cpython-89feabc7f5308e3190909f47fce225df28a65062.tar.gz
cpython-89feabc7f5308e3190909f47fce225df28a65062.tar.bz2
The socket module now always uses the _socketobject wrapper class, even on
platforms which have dup(2). The makefile() method is built directly on top of the socket without duplicating the file descriptor, allowing timeouts to work properly. Includes a new test case (urllibnet) which requires the network resource. Closes bug 707074.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_urllibnet.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
new file mode 100644
index 0000000..3af2491
--- /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()