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') |
Walter Dörwald | 21d3a32 | 2003-05-01 17:45:56 +0000 | [diff] [blame] | 26 | test_support.run_unittest(URLTimeoutTest) |
Skip Montanaro | 89feabc | 2003-03-30 04:54:24 +0000 | [diff] [blame] | 27 | |
| 28 | if __name__ == "__main__": |
| 29 | test_main() |