diff options
-rw-r--r-- | Lib/test/test_urllib2.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 8a7cf65..8daa73b 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -670,15 +670,25 @@ class MiscTests(unittest.TestCase): else: self.assert_(False) +class NetworkTests(unittest.TestCase): + def test_range (self): + req = urllib2.Request("http://www.python.org", + headers={'Range': 'bytes=20-39'}) + result = urllib2.urlopen(req) + data = result.read() + self.assertEqual(len(data), 20) + + def test_main(verbose=None): from test import test_sets - test_support.run_unittest( - TrivialTests, - OpenerDirectorTests, - HandlerTests, - MiscTests, - ) + tests = (TrivialTests, + OpenerDirectorTests, + HandlerTests, + MiscTests) + if test_support.is_resource_enabled('network'): + tests += (NetworkTests,) + test_support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) |