From bd3200fa2bfa8a73d56de16b68d33d2e25583875 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 29 Jun 2004 13:15:46 +0000 Subject: [PATCH] Add test case for bug #912845: requesting an HTTP byte range doesn't work --- Lib/test/test_urllib2.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 8a7cf650607..8daa73bac52 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)