diff -r 020ebe0be33e Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py Sat Apr 23 17:56:06 2011 +0200 +++ b/Lib/test/test_urllib.py Sun Apr 24 19:42:29 2011 -0300 @@ -390,6 +390,23 @@ self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) + + def test_progresshook_8193_bytes(self): + # Test on 8193 byte file. Should call progresshook only 3 times (once + # when the "network connection" is established, once for the next 8192 + # bytes, and once for the last byte). + report = [] + def hooktester(read, size, _report=report): + _report.append((read, size)) + srcFileName = self.createNewTempFile(b"x" * 8193) + urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName), + support.TESTFN, progresshook=hooktester) + self.assertEqual(len(report), 3) + self.assertEqual(report[0][0], 0) + self.assertEqual(report[0][1], 8193) + + self.assertEqual(report[1][0], 8192) + self.assertEqual(report[2][0], 8193) class QuotingTests(unittest.TestCase): """Tests for urllib.quote() and urllib.quote_plus()