@@ -384,11 +384,11 @@ def test_copy(self):
384384
385385 def test_reporthook (self ):
386386 # Make sure that the reporthook works.
387- def hooktester (count , block_size , total_size , count_holder = [0 ]):
388- self .assertIsInstance (count , int )
389- self .assertIsInstance (block_size , int )
390- self .assertIsInstance (total_size , int )
391- self .assertEqual (count , count_holder [0 ])
387+ def hooktester (block_count , block_read_size , file_size , count_holder = [0 ]):
388+ self .assertIsInstance (block_count , int )
389+ self .assertIsInstance (block_read_size , int )
390+ self .assertIsInstance (file_size , int )
391+ self .assertEqual (block_count , count_holder [0 ])
392392 count_holder [0 ] = count_holder [0 ] + 1
393393 second_temp = "%s.2" % support .TESTFN
394394 self .registerFileForCleanUp (second_temp )
@@ -399,8 +399,8 @@ def hooktester(count, block_size, total_size, count_holder=[0]):
399399 def test_reporthook_0_bytes (self ):
400400 # Test on zero length file. Should call reporthook only 1 time.
401401 report = []
402- def hooktester (count , block_size , total_size , _report = report ):
403- _report .append ((count , block_size , total_size ))
402+ def hooktester (block_count , block_read_size , file_size , _report = report ):
403+ _report .append ((block_count , block_read_size , file_size ))
404404 srcFileName = self .createNewTempFile ()
405405 urllib .request .urlretrieve (self .constructLocalFileUrl (srcFileName ),
406406 support .TESTFN , hooktester )
@@ -410,31 +410,31 @@ def hooktester(count, block_size, total_size, _report=report):
410410 def test_reporthook_5_bytes (self ):
411411 # Test on 5 byte file. Should call reporthook only 2 times (once when
412412 # the "network connection" is established and once when the block is
413- # read). Since the block size is 8192 bytes, only one block read is
414- # required to read the entire file.
413+ # read).
415414 report = []
416- def hooktester (count , block_size , total_size , _report = report ):
417- _report .append ((count , block_size , total_size ))
415+ def hooktester (block_count , block_read_size , file_size , _report = report ):
416+ _report .append ((block_count , block_read_size , file_size ))
418417 srcFileName = self .createNewTempFile (b"x" * 5 )
419418 urllib .request .urlretrieve (self .constructLocalFileUrl (srcFileName ),
420419 support .TESTFN , hooktester )
421420 self .assertEqual (len (report ), 2 )
422- self .assertEqual (report [0 ][1 ], 8192 )
423- self .assertEqual (report [0 ][ 2 ], 5 )
421+ self .assertEqual (report [0 ][1 ], 0 )
422+ self .assertEqual (report [1 ][ 1 ], 5 )
424423
425424 def test_reporthook_8193_bytes (self ):
426425 # Test on 8193 byte file. Should call reporthook only 3 times (once
427426 # when the "network connection" is established, once for the next 8192
428427 # bytes, and once for the last byte).
429428 report = []
430- def hooktester (count , block_size , total_size , _report = report ):
431- _report .append ((count , block_size , total_size ))
429+ def hooktester (block_count , block_read_size , file_size , _report = report ):
430+ _report .append ((block_count , block_read_size , file_size ))
432431 srcFileName = self .createNewTempFile (b"x" * 8193 )
433432 urllib .request .urlretrieve (self .constructLocalFileUrl (srcFileName ),
434433 support .TESTFN , hooktester )
435434 self .assertEqual (len (report ), 3 )
436- self .assertEqual (report [0 ][1 ], 8192 )
437- self .assertEqual (report [0 ][2 ], 8193 )
435+ self .assertEqual (report [0 ][1 ], 0 )
436+ self .assertEqual (report [1 ][1 ], 8192 )
437+ self .assertEqual (report [2 ][1 ], 1 )
438438
439439
440440class urlretrieve_HttpTests (unittest .TestCase , FakeHTTPMixin ):
0 commit comments