MCPcopy Index your code
hub / github.com/python/cpython / test_reporthook_5_bytes

Method test_reporthook_5_bytes

Lib/test/test_urllib.py:710–722  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

708 self.assertEqual(report[0][2], 0)
709
710 def test_reporthook_5_bytes(self):
711 # Test on 5 byte file. Should call reporthook only 2 times (once when
712 # the "network connection" is established and once when the block is
713 # read).
714 report = []
715 def hooktester(block_count, block_read_size, file_size, _report=report):
716 _report.append((block_count, block_read_size, file_size))
717 srcFileName = self.createNewTempFile(b"x" * 5)
718 urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName),
719 os_helper.TESTFN, hooktester)
720 self.assertEqual(len(report), 2)
721 self.assertEqual(report[0][2], 5)
722 self.assertEqual(report[1][2], 5)
723
724 def test_reporthook_8193_bytes(self):
725 # Test on 8193 byte file. Should call reporthook only 3 times (once

Callers

nothing calls this directly

Calls 4

createNewTempFileMethod · 0.95
constructLocalFileUrlMethod · 0.95
urlretrieveMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected