Skip Montanaro | 89feabc | 2003-03-30 04:54:24 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import unittest |
| 4 | from test import test_support |
| 5 | |
| 6 | import socket |
| 7 | import urllib2 |
| 8 | import sys |
| 9 | |
| 10 | class URLTimeoutTest(unittest.TestCase): |
| 11 | |
| 12 | TIMEOUT = 10.0 |
| 13 | |
| 14 | def setUp(self): |
| 15 | socket.setdefaulttimeout(self.TIMEOUT) |
| 16 | |
| 17 | def tearDown(self): |
| 18 | socket.setdefaulttimeout(None) |
| 19 | |
| 20 | def testURLread(self): |
| 21 | f = urllib2.urlopen("http://www.python.org/") |
| 22 | x = f.read() |
| 23 | |
| 24 | def test_main(): |
| 25 | test_support.requires('network') |
| 26 | |
| 27 | suite = unittest.TestSuite() |
| 28 | suite.addTest(unittest.makeSuite(URLTimeoutTest)) |
| 29 | test_support.run_suite(suite) |
| 30 | |
| 31 | if __name__ == "__main__": |
| 32 | test_main() |